Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! While resolving: @nestjs/[email protected]

While installing node_modules, I use the --legacy-peer-deps or --force flags. This works fine on windows on my system locally, but it doesn't work while deploying the project in ubuntu server!

This is the error I get:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @nestjs/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/mongoose
npm ERR!   mongoose@"6.0.1" from the root project
npm ERR!   mongoose@"*" from @types/[email protected]
npm ERR!   node_modules/@types/mongoose
npm ERR!     dev @types/mongoose@"5.11.96" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer mongoose@"^5.11.15 || ^5.12.4" from @nestjs/[email protected]
npm ERR! node_modules/@nestjs/mongoose
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/mongoose
npm ERR!   peer mongoose@"^5.11.15 || ^5.12.4" from @nestjs/[email protected]
npm ERR!   node_modules/@nestjs/mongoose
npm ERR!     @nestjs/mongoose@"8.0.1" 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\Admin\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\Admin\AppData\Local\npm-cache\_logs\2022-06-14T08_44_12_502Z-debug-0.log
like image 231
Faraz Khan Avatar asked Jan 20 '26 13:01

Faraz Khan


2 Answers

It means you have dependency conflicts. So try running the following options one by one.

  1. Remove node_modules and package-lock.json and then run

    npm install
    
  2. Or try clearing out npm cache

    npm cache clean --force
    
  3. Or run the command with the --legacy-peer-deps option

    npm install --legacy-peer-deps
    
  4. Or run the command with the --force option

    npm install --force
    
like image 190
yanir midler Avatar answered Jan 23 '26 02:01

yanir midler


Got the same error. I tried many different things. First i cleared the cach.

npm cache clean --forc

After that, i deleted package.json and node_modules and reinstalled npm with this command.

npm install --legacy-peer-deps

Nothing really worked. The only command that worked was:

npm config set legacy-peer-deps true

After that i can install everything with npm.

like image 24
Max Siegel Avatar answered Jan 23 '26 02:01

Max Siegel