ProjectStack
npm

npm ERR! code ERESOLVE — unable to resolve dependency tree

npm can't resolve your project's dependencies because two packages require conflicting versions of the same dependency. npm 7+ enforces strict peer dependency resolution by default.

Common causes

  • A package requires a peer dependency version that conflicts with what's already installed
  • You upgraded a package but its peer dependencies haven't been updated to match
  • Two different packages require incompatible versions of the same shared library
  • npm 7+ changed the default peer dependency behavior — projects that worked with npm 6 may now fail

How to fix it

  1. Use the legacy peer deps flag to bypass the conflict: npm install --legacy-peer-deps
  2. Or force install (less safe): npm install --force
  3. Identify the conflicting packages from the error output and try upgrading them together
  4. Check if a compatible version exists: npm info <package> peerDependencies

Example

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: [email protected] npm ERR! Found: [email protected] npm ERR! node_modules/react npm ERR! react@"^18.2.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^17.0.0" from [email protected]

Running npm install when a package requires a different React version than what's installed

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.