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.
Fixes npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from [email protected]npm ERR! ERESOLVE unable to resolve dependency treenpm ERR!npm ERR! Found: [email protected]npm ERR! node_modules/reactnpm ERR!npm ERR! Could not resolve dependency:npm ERR! peer react@"^17.0.0" from [email protected]npm ERR! code ERESOLVE
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.
npm shows detailed conflict info:
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from [email protected]This 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
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.