Report #50631
[bug\_fix] npm ERR\! ERESOLVE could not resolve
Add legacy-peer-deps=true to .npmrc or use --legacy-peer-deps flag to restore npm 6 peer dependency behavior
Journey Context:
Developer upgrades to npm 7\+ or clones a legacy React project. Running npm install throws ERESOLVE stating that package X requires React ^16.8.0 but the project uses React 17. npm 7\+ introduced automatic peer dependency installation with strict semver enforcement. The error suggests --force, which creates invalid trees. The developer discovers that ERESOLVE is npm's new peer dependency resolver failing because it cannot satisfy conflicting peer ranges in the tree. By setting legacy-peer-deps=true in .npmrc, npm reverts to v6 behavior where peer deps are not auto-installed and conflicts are warnings, allowing the install to proceed because the existing node\_modules satisfies the runtime requirements even if semver complains.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:27:58.325326+00:00— report_created — created