npm ERR! ERESOLVE unable to resolve dependency tree
ERESOLVE unable to resolve dependency tree
Verified against npm 11 docs (cli/commands/npm-install.md), npm RFC #39 (peer deps), Stack Overflow #66239691 · Updated April 2026
> quick_fix
A package requires a peer-dependency version that conflicts with another package in your tree. Try `npm install --legacy-peer-deps` to restore npm-6 behaviour, or update the conflicting packages to compatible versions.
# Quick escape hatch (npm 7+)
npm install --legacy-peer-deps
# Or accept pre-release versions
npm install --force
# Better: find the conflict and upgrade
npm ls <conflicting-package>What causes this error
npm 7 and later strictly enforce peer dependencies. If package A wants React 17 as a peer and package B wants React 18, npm refuses to install either version because it would violate one package's contract. In npm 6, peer deps were only warned about — npm 7+ made them blocking.
How to fix it
- 01
step 1
Read the error output to find the conflict
ERESOLVE shows `Found: X@version` and `Could not resolve Y@version` — those are the conflicting packages.
- 02
step 2
Try --legacy-peer-deps first
This restores npm 6 behaviour and usually works. Safe for most React, Vue, and Angular apps where the peer conflict is a known ecosystem lag.
npm install --legacy-peer-deps - 03
step 3
For a real fix, update the conflicting package
Check which package requires the stricter peer. Often it's a transitive dep — upgrade your direct dep to a newer version that has a compatible peer.
- 04
step 4
Pin versions with overrides if upstream won't update
In package.json, use the `overrides` field (npm 8.3+) to force a specific version of a transitive dep.
{ "overrides": { "react": "$react" } }
Frequently asked questions
Is --legacy-peer-deps safe?
For most cases, yes. It mirrors npm 6 behaviour which worked for years. Risk: a true peer-dep incompatibility will manifest as a runtime error instead of an install error.
What's the difference between --force and --legacy-peer-deps?
--force installs everything regardless of conflicts. --legacy-peer-deps only relaxes peer-dep rules. --legacy-peer-deps is safer.
Why does pnpm not have this problem?
pnpm uses a different resolution algorithm and handles peer deps per-package rather than globally.