How to fix npm ERR! code ERESOLVE in npm

npmINTERMEDIATEMEDIUMUpdated Dec 6, 2025· 180 views

The ERESOLVE error occurs when npm cannot find a version that satisfies all dependency requirements. This typically indicates conflicting peer dependencies or impossible version constraints.

Quick fix

Fixes npm ERR! code ERESOLVE

npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from some-package@1.0.0
  1. Read the error carefully
  2. Use --legacy-peer-deps
  3. Use --force
  4. Update conflicting packages
npm — error
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from some-package@1.0.0
npm ERR! code ERESOLVE

What this error means

npm 7+ introduced stricter peer dependency handling. ERESOLVE occurs when npm's dependency resolver cannot find a valid dependency tree - usually because different packages require conflicting versions of the same dependency. This error provides detailed information about which packages are conflicting, helping you understand and resolve the dependency conflict.

Typical symptoms

  • npm install fails with ERESOLVE
  • Error shows dependency tree conflict
  • Peer dependency requirements conflict
  • Upgrading package causes error
  • Works with npm 6 but fails with npm 7+
  • New package installation breaks existing

Common causes

  1. Conflicting peer dependency versions
  2. Package requires older version of dependency
  3. Multiple packages need incompatible versions
  4. Package ecosystem in transition
  5. Outdated package depending on old versions
  6. Direct dependency conflicts with transitive

How to fix "npm ERR! code ERESOLVE"

1Read the error carefully

npm shows detailed conflict info:

bash
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from some-package@1.0.0

This shows exactly what conflicts.

2Use --legacy-peer-deps

Use npm 6 style dependency resolution:

bash
npm install --legacy-peer-deps

This ignores peer dependency conflicts like npm 6 did.

3Use --force

Force installation (use cautiously):

bash
npm install --force

⚠️ This may cause runtime issues if dependencies truly are incompatible.

4Update conflicting packages

Find compatible versions:

bash
# Check for updates
npm outdated

# Update specific package
npm update package-name

# Check peer dependencies
npm view some-package peerDependencies
5Use npm overrides

Force specific versions:

json
{
  "overrides": {
    "react": "18.2.0"
  }
}

This forces all packages to use your specified version.

6Check for alternative packages

If a package causes persistent issues:

1. Check for newer version
2. Look for fork with updated deps
3. Consider alternative package
4. Open issue with package maintainer

Advanced notes

ERESOLVE is often encountered when upgrading major versions (React 17 to 18, etc.). The npm overrides feature (npm 8.3+) allows forcing specific versions throughout the tree. For Yarn users, the resolutions field provides similar functionality. Consider using npm-check-updates to identify safe upgrade paths. In monorepos, hoist conflicts may require per-package overrides.

Frequently asked questions

What does "npm ERR! code ERESOLVE" mean?
npm 7+ introduced stricter peer dependency handling. ERESOLVE occurs when npm's dependency resolver cannot find a valid dependency tree - usually because different packages require conflicting versions of the same dependency. This error provides detailed information about which packages are conflicting, helping you understand and resolve the dependency conflict.
How do I fix "npm ERR! code ERESOLVE"?
The ERESOLVE error occurs when npm cannot find a version that satisfies all dependency requirements. This typically indicates conflicting peer dependencies or impossible version constraints.
What causes "npm ERR! code ERESOLVE"?
Conflicting peer dependency versions Package requires older version of dependency Multiple packages need incompatible versions
Is the "npm ERR! code ERESOLVE" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading