SoFunction
Updated on 2025-04-06

How to resolve a certain dependency version conflict when npm i downloads dependencies

npm i There is a certain dependency version conflict when downloading dependencies

An error occurred when downloading npm i dependency, probably the version problem

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @wangeditor/[email protected]
npm ERR! Found: @wangeditor/[email protected]
npm ERR! node_modules/@wangeditor/editor
npm ERR!   @wangeditor/editor@"5.0.1" from the root project
npm ERR!   peer @wangeditor/editor@">=5.0.0" from @wangeditor/[email protected]
npm ERR!   node_modules/@wangeditor/plugin-formula
npm ERR!     @wangeditor/plugin-formula@"^1.0.8" from the root project
npm ERR!   1 more (@wangeditor/plugin-mention)
npm ERR!

Solution

Add --legacy-peer-deps after npm install to solve it

npm i --legacy-peer-deps

In fact, the meaning of this command itself is to let it ignore the conflicts caused by dependencies when downloading dependencies (this is my personal understanding!)

npm download error npm ERR code ERESOLVE

Report an error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @vue/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint-plugin-vue
npm ERR!   peer eslint-plugin-vue@"^8.0.1" from @vue/[email protected]
npm ERR!   node_modules/@vue/eslint-config-typescript
npm ERR!     dev @vue/eslint-config-typescript@"^9.1.0" from the root project
npm ERR!   dev eslint-plugin-vue@"^8.0.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer eslint-plugin-vue@"^7.0.0" from @vue/[email protected]
npm ERR! node_modules/@vue/eslint-config-standard
npm ERR!   dev @vue/eslint-config-standard@"^6.1.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]    
t 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\danxibao\AppData\Local\npm-cache\ for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\danxibao\AppData\Local\npm-cache\_logs\2022-05-29T07_02_09_565Z

solve:

  • When downloading npm
  • --legacy-peer-deps
  • In NPM v7, peerDependencies is now installed by default.

In many cases, npm version issues can lead to download conflicts, which interrupts the installation process.

The --legacy-peer-deps flag was introduced in v7, with the purpose of bypassing peerDependency automatic installation;

It tells NPM to ignore the problems of the same modules but different versions between the modules introduced in the project and continue to install them, ensuring that the different versions of modules used by each introduced dependencies coexist on itself.

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.