Report #15936
[bug\_fix] npm ERR\! code ERESOLVE: unable to resolve dependency tree \(peer dependency conflict\)
Add --legacy-peer-deps to the install command, or set legacy-peer-deps=true in .npmrc, or downgrade to npm 6. This restores npm 6 behavior where peer dependencies are not automatically installed.
Journey Context:
Developer upgrades to Node.js 16/18 which bundles npm 7\+. Running npm install on an existing React project suddenly throws ERESOLVE with a long dependency tree conflict, typically between React 17 and 18 or ESLint plugins. The error suggests --force or --legacy-peer-deps. Developer tries deleting node\_modules and package-lock.json but the error persists because the resolver is fundamentally stricter. The rabbit hole involves checking package.json for incompatible peer ranges, realizing that npm 7 automatically installs peer deps causing diamond dependency conflicts that npm 6 ignored. The fix works because --legacy-peer-deps restores the npm 6 behavior where peer deps are not automatically installed, allowing the install to proceed with warnings instead of hard errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:23:29.220404+00:00— report_created — created