davood beheshti
davood beheshti

Reputation: 968

Getting an error when adding material in angular version 14.0.0

I have just started a project with Angular version 14.0.0 and the project is completely raw and I have not made the slightest changes in it. But when I try to install @angular/material it gives me this error that we need to update the version of @angular/[email protected]?

All the packages I have in the package.json section

{
 "name": "nested-forms-angular",
 "version": "0.0.0",
 "scripts": {
   "ng": "ng",
   "start": "ng serve",
   "build": "ng build",
   "watch": "ng build --watch --configuration development",
   "test": "ng test"
 },
 "private": true,
 "dependencies": {
   "@angular/animations": "^14.0.0",
   "@angular/common": "^14.0.0",
   "@angular/compiler": "^14.0.0",
   "@angular/core": "^14.0.0",
   "@angular/forms": "^14.0.0",
   "@angular/platform-browser": "^14.0.0",
   "@angular/platform-browser-dynamic": "^14.0.0",
   "@angular/router": "^14.0.0",
   "rxjs": "~7.5.0",
   "tslib": "^2.3.0",
   "zone.js": "~0.11.4"
 },
 "devDependencies": {
   "@angular-devkit/build-angular": "^14.0.0",
   "@angular/cli": "~14.0.0",
   "@angular/compiler-cli": "^14.0.0",
   "@types/jasmine": "~4.0.0",
   "jasmine-core": "~4.1.0",
   "karma": "~6.3.0",
   "karma-chrome-launcher": "~3.1.0",
   "karma-coverage": "~2.2.0",
   "karma-jasmine": "~5.0.0",
   "karma-jasmine-html-reporter": "~1.7.0",
   "typescript": "~4.7.2"
 }
}

The error I get during installation

enter image description here

Upvotes: 0

Views: 474

Answers (1)

Antoniossss
Antoniossss

Reputation: 32550

You are trying to install the latest version of angular material by doing npm i @angular/material with no version constraints specified.

Error says it requires @angular/animations in version >= 15.x.x && <= 16.x.x but you have stated in your package.json that your version of animations module will be ^14.0.0 which is a "newest minor release of 14.x" and that resolves to 14.12.12

You have to update all dependencies first (or in the single run)

Since you are have included angular/cli use it to upgrade your project. Check the guide on how to update applications without any problems here https://update.angular.io/

Upvotes: 2

Related Questions