Report #38845
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree
Run npm install with the --legacy-peer-deps flag. Root cause: npm v7\+ introduced strict peer dependency resolution per RFC: Peer Dependencies v2. When nested transitive dependencies declare overlapping but non-intersecting peer version ranges \(e.g., one expects React 17, another allows 17\|\|18\), the resolver halts instead of picking one arbitrarily. The flag reverts to npm v6 behavior which ignored peer conflicts and hoisted whatever was present, allowing manual resolution by the developer.
Journey Context:
You clone a legacy React 17 project and run npm install. The terminal explodes with ERESOLVE errors mentioning [email protected] vs [email protected] at conflicting peer dependencies. You try npm install --force, which seems to work but breaks runtime with duplicate React copies \(Invalid Hook Call\). You dig into node\_modules and see @testing-library/react pulling React 18 despite your root being 17. You check npm ls react and see unmet peer dependency warnings cascading. After reading the npm v7.0.0 changelog, you realize npm changed peer dep resolution to strict intersection logic \(RFC: Peer Dependencies v2\). You try --legacy-peer-deps and installation succeeds because it ignores the strict intersection check, allowing the nested library to use the root React 17 via hoisting despite its peer declaration technically allowing 18.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:40:26.813054+00:00— report_created — created