npm ERR! ERESOLVE unable to resolve dependency tree
Fix npm ERESOLVE dependency resolution errors. Learn to use --legacy-peer-deps, update packages, and resolve conflicting peer dependency versions.
What Does This Error Mean?
The npm ERESOLVE error occurs when npm cannot find a valid combination of package versions that satisfies all peer dependency requirements across your project's dependency tree. This strict peer dependency resolution was introduced in npm v7 to prevent incompatible package combinations.
Common Causes
Two packages require different incompatible versions of the same peer dependency
Installing a package that requires a newer version of React/Vue/Angular than you have
Mixing major versions of a peer dependency (e.g., React 17 vs React 18)
A package requires a peer dependency that is not installed
Outdated lockfile referencing removed or conflicting package versions
Monorepo with multiple packages using different versions of shared dependencies
How to Fix It
Use --legacy-peer-deps (quick fix)
Revert to npm v6-style peer dependency resolution (accepts any version).
# Install with legacy peer dep resolution npm install --legacy-peer-deps # Add to .npmrc for permanent setting echo "legacy-peer-deps=true" >> .npmrc # Or use the npm config command npm config set legacy-peer-deps true
Update packages to compatible versions
Upgrade your project's dependencies to versions compatible with the peer dependencies.
# Check which packages are outdated npm outdated # Update specific packages npm update react react-dom # Update all packages (major versions) npm install -g npm-check-updates ncu -u npm install
Use overrides to force versions
Force specific versions of transitive dependencies using npm overrides (npm v8+).
// package.json
{
"overrides": {
"react": "18.2.0",
"react-dom": "18.2.0"
}
}
// Or override a nested dependency
{
"overrides": {
"some-package": {
"react": "18.2.0"
}
}
}Clear cache and reinstall
A corrupted cache or lockfile can cause resolution errors.
# Clean everything rm -rf node_modules package-lock.json npm cache clean --force # Reinstall npm install # If still failing, try with verbose logging npm install --legacy-peer-deps --loglevel verbose
Related Tools
Use these tools to debug and fix this error:
Related Errors
Other common errors in this category:
401 Unauthorized Error
Learn what a 401 Unauthorized error means, common causes, and how to fix authentication failures in your web applications.
403 Forbidden Error
Learn what 403 Forbidden means, how it differs from 401, and how to fix access denied errors in your applications.
404 Not Found Error
Learn what 404 Not Found means, common causes, and how to fix broken links and missing resources on your website or API.
429 Too Many Requests Error
Learn what 429 Too Many Requests means, how rate limiting works, and how to handle or avoid hitting API rate limits.
Frequently Asked Questions
What changed in npm v7 that causes ERESOLVE?
npm v7 introduced strict peer dependency auto-installation. In npm v6, peer dependency warnings were just warnings — npm would install anyway. In npm v7+, failing to satisfy a peer dependency is an error. The --legacy-peer-deps flag restores npm v6 behavior.
Is --legacy-peer-deps safe to use?
It depends. If peer dependency conflicts are minor (e.g., React 18.0.0 vs 18.2.0), --legacy-peer-deps is usually safe. If the conflicts are major (e.g., React 16 vs React 18), you may encounter runtime issues. Prefer resolving the conflict properly by updating dependencies.