Search code examples
angularcookiesngx-cookie-service

Cannot install ngx-cookie-service in angular project


I am working on an angular project in where I need to use cookies. I am installing ngx-cookie-service module from https://www.npmjs.com/package/ngx-cookie-service But the module is not being installed, its showing the following errors

npm WARN config global --global, --local are deprecated. Use --location=global instead.

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: chatbot-frontend@0.0.0 npm ERR! Found: @angular/common@11.1.2 npm ERR! node_modules/@angular/common npm ERR! @angular/common@"~11.1.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @angular/common@"^15.0.0" from ngx-cookie-service@15.0.0
npm ERR! node_modules/ngx-cookie-service npm ERR!
ngx-cookie-service@"*" 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. npm ERR! npm ERR! See C:\Users\Deepak Mane\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\Deepak Mane\AppData\Local\npm-cache_logs\2023-01-01T13_59_03_695Z-debug-0.log

please suggest me a way to use cookie services.


Solution

  • Try

    npm install ngx-cookie-service@11.0.2
    

    You need to align the library version with the angular version used in your project. You can find the proper version on the page you linked in your question.