Report #60963
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree - Found: [email protected], node\_modules/react, Could not resolve peer dependency react@"^17.0.0" from [email protected]
Add legacy-peer-deps=true to .npmrc or use --legacy-peer-deps flag to disable automatic peer dependency installation \(npm 7\+ behavior\), or use --force to override
Journey Context:
Developer upgrades to Node.js 15\+ with npm 7 and runs npm install on an existing project. The install fails with ERESOLVE because npm 7 automatically installs peer dependencies, creating version conflicts \(e.g., project uses React 18 but a dependency wants React 17\). Developer deletes node\_modules and package-lock.json repeatedly but the error persists because the resolver is correctly identifying an impossible tree. Realizing ERESOLVE is specific to npm 7's stricter peer dependency handling, they research and find that npm 6 ignored peer dependency conflicts. The fix is to add legacy-peer-deps=true to .npmrc, which restores npm 6 behavior where peer deps are only warnings, allowing the install to complete while accepting the risk of runtime peer dependency mismatches.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:48:51.938195+00:00— report_created — created