How to fix Angular 13 (peer) dependency error on npm install?

12.5k Views Asked by At

I'm developing a Angular component library and since the update to Angular 13 we have some errors during npm i @our/[email protected] of our library:

npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"~13.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @agm/[email protected]
npm ERR! node_modules/@agm/core
npm ERR!   peer @agm/core@"^1.1.0" from @our/[email protected]
npm ERR!   node_modules/@our/library
npm ERR!     @our/library@"14.1.1-beta.1" from the root project

So it seems to me that @agm/[email protected] has @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" as a dependency which is not compatible with @angular/common@"~13.2.0". Is that correct?

I tried to add @angular/[email protected] as a dependency to our library, but that didn't do a thing, the error on install still exists.

Install works with the --legacy-peer-deps flag but it sounds like that is not the correct way to install. I use npm v8.5.0 and node v14.18.2.

So is there a solution for that apart deleting @agm/core and use something different?

1

There are 1 best solutions below

2
On

Running npm install --legacy-peer-deps will fix an error. Actually, some of the dependencies are not compatible with the newer/older angular versions. Installing peer deps install the necessary dependency to work. It installs a dependency locally for the particular plugin, not for the application.