Report #55782
[bug\_fix] npm ERR\! ERESOLVE could not resolve dependency tree
The root cause is npm 7\+'s stricter peer dependency resolution algorithm which automatically installs peer deps unlike npm 6, causing conflicts when multiple packages require incompatible peer versions \(e.g., React 17 vs 18\). Use --legacy-peer-deps to revert to npm 6's lenient behavior \(npm install --legacy-peer-deps\), or use --force to override. The proper fix is to resolve version incompatibilities by upgrading/downgrading packages to compatible ranges or using overrides in package.json.
Journey Context:
You upgrade npm to version 8 or 9, then run npm install on an existing project that worked fine before. Suddenly you see ERESOLVE errors stating 'could not resolve dependency tree' and mentioning peer dependency conflicts between react@17 and react@18. You try deleting node\_modules and package-lock.json, but the error persists. You search the error code and discover npm 7\+ changed peer dependency handling to be strict by default. You try --legacy-peer-deps and it works immediately because it tells npm to ignore the strict peer dependency resolution algorithm that was trying to automatically install both React versions simultaneously, which is impossible.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:07:26.498795+00:00— report_created — created