7

I am trying to install node_modules for a project using npm install. But it's failing.

Error Log :

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: my-first-app@0.0.0
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~11.0.0" from the root project
npm ERR!   peer @angular/compiler@"11.0.9" from @angular/compiler-cli@11.0.9
npm ERR!   node_modules/@angular/compiler-cli
npm ERR!     dev @angular/compiler-cli@"~11.0.0" from the root project
npm ERR!     peer @angular/compiler-cli@"^11.0.0" from @angular-devkit/build-angular@0.1100.7
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~0.1100.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"11.1.2" from @angular/localize@11.1.2
npm ERR! node_modules/@angular/localize
npm ERR!   peerOptional @angular/localize@"^11.0.0" from @angular-devkit/build-angular@0.1100.7
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1100.0" 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 /Users/amit/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amit/.npm/_logs/2021-02-04T17_58_24_981Z-debug.log

Logs suggest to use either npm install --force or npm install --legacy-peer-deps

I want to understand the basic difference between npm install --force and npm install --legacy-peer-deps.

Also, which one is more preferable to be used, just in case if performance of --force is better than --legacy-peer-deeps or vice-versa ?

Any suggestions/pointers are highly appreciable. Thanks!

Amit kumar
  • 2,169
  • 10
  • 25
  • 36
  • 1
    Does this answer your question? [npm: When to use \`--force\` and \`--legacy-peer-deps\`](https://stackoverflow.com/questions/66020820/npm-when-to-use-force-and-legacy-peer-deps) – Joe Feb 05 '21 at 03:57
  • 1
    Thanks @Joe! The question you suggested is similar to mine, But I am not really clear about the concept after going through the answer. It would be really helpful if one could help me understand the basic difference in Leyman's term. – Amit kumar Feb 05 '21 at 04:05
  • I have updated the question for more clarity about what I am looking for, specifically. – Amit kumar Feb 05 '21 at 04:12

1 Answers1

0

The differences between the two are below

--legacy-peer-deps : ignores all peerDependencies when installing, in the style of npm version 4 till version 6

--strict-peer-deps: fail and abort the install process for any conflicting peerDependencies when encountered. By default, npm will ony crash for peerDependencies conflicts caused by the direct dependencies of the root project.

--forces : will force npm to fetch remote resources even if a local copy exists on disk.

Surya R Praveen
  • 3,393
  • 1
  • 24
  • 25