Home > database >  Angular 13 dependencies
Angular 13 dependencies

Time:03-22

I recently (month ago) update the angular of my project to version 13.2.2, a few problems but could make it work and run, making deploys. The last Thursday I start having a problem with ng build, saying that one of my libraries (made for the project) needed a superior version of angular core because it used angular animations in version 13.3.0. So I don't have this version install not in my project, not in my libraries both have core and animation in version 13.2.2. My question is why when angular team release a new version (13.3.0)(last Thursday) my project automatically ask for that version to make a build. I didn´t change any version or did a npm install. How can I make my project stop looking for the core 13.3.0.

Error in my library when do npm list

npm ERR! peer dep missing: @angular/[email protected], required by @angular/[email protected]

Error when deploying the project

npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"~13.2.2" from the root project
npm ERR!   peer @angular/core@"~13.2.2" from @[email protected]
npm ERR!   node_modules/@MYLIBRARY
npm ERR!     @MYLIBRARY@"^0.5.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"13.3.0" from @angular/[email protected]
npm ERR! node_modules/@angular/animations
npm ERR!   @angular/animations@"^13.2.2" from the root project
npm ERR!   peer @angular/animations@"^13.2.2" from @[email protected]
npm ERR!   node_modules/@MYLIBRARY
npm ERR!     @MYLIBRARY@"^0.5.3" from the root project

package my library:

  "peerDependencies": {
    "@angular/common": "~13.2.2",
    "@angular/core": "~13.2.2",
    "@angular/animations": "^13.2.2",
    "@angular/cdk": "~13.2.2",
    "@angular/material": "^13.2.2"
  },
  "dependencies": {
    "tslib": "^2.3.1"
  }

package of my project:

 "@angular/animations": "^13.2.2",
 "@angular/cdk": "^13.2.2",
 "@angular/common": "~13.2.2",
 "@angular/compiler": "~13.2.2",
 "@angular/core": "~13.2.2",

Meanwhile, I delete node_modules and package-lock.json in both project and libraries to see if it fix, but didn't. Now I can see that in package-lock.json mentions angular 13.3.0. But why if I didn't do any updates.

CodePudding user response:

Pls see this node js documentation. There is a pretty well explanation for your problem.

https://nodejs.dev/learn/the-package-lock-json-file

In package.json you can set which versions you want to upgrade to (patch or minor), using the semver notation, for example:

  • if you write ~0.13.0, you want to only update patch releases: 0.13.1 is ok, but 0.14.0 is not.
  • if you write ^0.13.0, you want to get updates that do not change the leftmost non-zero number: 0.13.1, 0.13.2 and so on.
  • If you write ^1.13.0, you will get patch and minor releases: 1.13.1, 1.14.0 and so on up to 2.0.0 but not 2.0.0.
  • if you write 0.13.0, that is the exact version that will be used, always

Change your package.json as below of you want the exact version,

 "@angular/animations": "13.2.2",
 "@angular/cdk": "13.2.2",
 "@angular/common": "13.2.2",
 "@angular/compiler": "13.2.2",
 "@angular/core": "13.2.2",
  • Related