How to fix npm ERR! code ERESOLVE in npm
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- Read the error carefully
- Use --legacy-peer-deps
- Use --force
- Update conflicting packages
npm ERR! ERESOLVE unable to resolve dependency treenpm ERR!npm ERR! Found: react@18.2.0npm ERR! node_modules/reactnpm ERR!npm ERR! Could not resolve dependency:npm ERR! peer react@"^17.0.0" from some-package@1.0.0npm 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
- Conflicting peer dependency versions
- Package requires older version of dependency
- Multiple packages need incompatible versions
- Package ecosystem in transition
- Outdated package depending on old versions
- Direct dependency conflicts with transitive
How to fix "npm ERR! code ERESOLVE"
npm shows detailed conflict info:
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.0This shows exactly what conflicts.
Use npm 6 style dependency resolution:
npm install --legacy-peer-depsThis ignores peer dependency conflicts like npm 6 did.
Force installation (use cautiously):
npm install --force⚠️ This may cause runtime issues if dependencies truly are incompatible.
Find compatible versions:
# Check for updates
npm outdated
# Update specific package
npm update package-name
# Check peer dependencies
npm view some-package peerDependenciesForce specific versions:
{
"overrides": {
"react": "18.2.0"
}
}This forces all packages to use your specified version.
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.