Home > Blockchain >  Angular. Dependency conflict when trying to install ngx-cookie
Angular. Dependency conflict when trying to install ngx-cookie

Time:01-03

I am trying to install the ngx-cookie package so I can use the CookieService in my application. However, I get the following dependency conflicts:

$ npm install ngx-cookie --save
npm ERR! code ERESOLVE
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.0.0" from the root project
npm ERR!   peer @angular/core@">9.0.0" from [email protected]
npm ERR!   node_modules/ngx-cookie
npm ERR!     ngx-cookie@"*" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"13.1.1" from @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   peer @angular/common@">9.0.0" from [email protected]
npm ERR!   node_modules/ngx-cookie
npm ERR!     ngx-cookie@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

I have tried to install ngx-cookie-service but I get the same error.

What am I to do? Is it a problem with the Angular version?

CodePudding user response:

This is not an angular issue. Its more to do with npm7 version.

In previous versions of npm (4-6), peer dependencies conflicts presented a warning that versions were not compatible, but would still install dependencies without an error. npm 7 will block installations if an upstream dependency conflict is present that cannot be automatically resolved.

Ideally you should not get this error as in ngx-cookie package, angular peer deps defined as > That mean it will be compatible with all the version of angular which is greater than 9.

As suggested in the error log either you the --force flag or --legacy-peer-deps (this behavior is similar to versions 4-6).

Reference:- https://github.blog/2021-02-02-npm-7-is-now-generally-available/

  • Related