Node.js4 min read2026-03-01
npm Dependency Conflict: ERESOLVE unable to resolve dependency tree
Troubleshoot npm peer dependency conflicts, conflicting version constraints, and package-lock issues.
Error Code / Stack Trace
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency treeProblem Overview
Two packages in your dependency tree require incompatible peer dependency versions of the same library (e.g. React 18 vs React 19).
Why Does This Happen?
- Upgraded a root package while third-party plugins still specify an older peerDependency range.
- npm v7+ strict peer dependency enforcement algorithm.
Step-by-Step Solution
Step 1: Run with --legacy-peer-deps
Bypass strict peer dependency locking if the package functions properly.
bash
npm install --legacy-peer-depsStep 2: Use npm overrides in package.json
Force all child dependencies to accept a specific unified version of the conflicting package.
json
{
"dependencies": {
"react": "^19.0.0"
},
"overrides": {
"react": "^19.0.0"
}
}Common Mistakes to Avoid
- •Deleting package-lock.json and running npm install, which can pull breaking minor/patch updates across all dependencies.
Prevention & Best Practices
- Audit outdated packages regularly using 'npm outdated'.
Frequently Asked Questions
What is the difference between dependencies and peerDependencies?
dependencies are installed privately inside a library. peerDependencies require the consumer application to provide the shared dependency instance.
Related Developer Solutions & Tools
Recommended Tools
Related Error Fixes