Cli: [BUG] unable to resolve dependency tree

Created on 4 Nov 2020  路  9Comments  路  Source: npm/cli

there is another bug, but has been closed.

Current Behavior:

npm install --save-dev webpack-dev-server

output:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^5.3.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from [email protected]
npm ERR! node_modules/webpack-dev-middleware
npm ERR!   webpack-dev-middleware@"^3.7.2" from [email protected]
npm ERR!   node_modules/webpack-dev-server
npm ERR!     dev webpack-dev-server@"^3.11.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/bergman/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bergman/.npm/_logs/2020-11-04T06_31_48_517Z-debug.log

Environment:

  • OS: macos 10.15.7
  • Node: 15.0.1
  • npm: 7.0.3
Bug Needs Triage Release 7.x

Most helpful comment

i had the same prob

npm install npm@latest -g
then
npm install webpack-dev-server --save-dev

working for me

All 9 comments

What happens with npm v7.0.8?

What happens with npm v7.0.8?

how can i install it? i install node, the npm is 7.0.3, how can i update it to 7.0.8?

@lornally You can grab the latest version of npm by running npm install npm@latest -g. After that's finished, run npm -v to confirm you have v7.0.8 installed.

we haven't actually tagged npm 7 as latest yet, but npm install -g npm@7 should do the trick for you

This seems like expected behavior. You have [email protected] installed and you're trying to install [email protected] which transitively peer-depends on webpack@^4.0.0. These webpack ranges are incompatible, as the error mentions.

You can fix it by using webpack@4 instead of webpack@5. webpack-dev-server@3 is not compatible with webpack@5.

(IMO, npm's output here is not very friendly. It's nice that it identifies all of the relevant packages, but if I didn't know much about peer dependencies, I could imagine being quite confused about what's wrong and what to do next. The message doesn't explicitly mention that it's a peer dependency issue -- it says "peer" but it also says "dev" and many other things -- and "fix the upstream dependency conflict" is not actionable.)

Working as designed, and better error messaging and handling in latest npm v7.

i had the same prob

npm install npm@latest -g
then
npm install webpack-dev-server --save-dev

working for me

@nlf 's solution doesn't work for me but @mvyunko 's does. The latter downgrades npm from version 7 to 6 however.

I had same problem and have done these steps:

  1. uninstall & install nodejs
  2. npm install npm
  3. npm install webpack-dev-server --save-dev
Was this page helpful?
0 / 5 - 0 ratings