Report #16490
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree npm ERR\! Could not resolve dependency: npm ERR\! peer react@"^17.0.0" from [email protected] npm ERR\! node\_modules/some-package npm ERR\! some-package@"^1.0.0" from the root project npm ERR\! Fix the upstream dependency conflict, or retry npm ERR\! this command with --force, or --legacy-peer-deps
Use the --legacy-peer-deps flag with npm install \(e.g., npm install --legacy-peer-deps\), or set legacy-peer-deps=true in the .npmrc file. This restores npm v6 behavior where peer dependencies are not automatically installed, preventing the conflict resolution algorithm from failing when two packages require different versions of the same peer \(e.g., React 17 vs 18\).
Journey Context:
Developer upgrades to Node.js 16\+ \(which ships npm 7\+\) or clones a project created with npm 6. Running npm install throws ERESOLVE, often involving React, ESLint, or TypeScript plugin ecosystems where peer dependencies are strict. The error shows a tree where package A wants React 17 and package B wants React 18. Developer tries --force, which installs a broken tree causing runtime 'invalid hook call' errors. They investigate npm's RFC 30 and learn that npm 7\+ auto-installs peer deps. Using --legacy-peer-deps disables this auto-installation, allowing the developer to manually ensure only one version of React exists at the top level, satisfying all peers and fixing the resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:48:12.762791+00:00— report_created — created