Report #46555
[bug\_fix] npm ERR\! code ERESOLVE npm ERR\! ERESOLVE unable to resolve dependency tree npm ERR\! Found: [email protected] npm ERR\! Could not resolve dependency: npm ERR\! peer react@"^17.0.0" from [email protected]
Run npm install with the --legacy-peer-deps flag, or migrate dependencies to compatible peer versions. Root cause: npm 7\+ automatically attempts to install peer dependencies and enforces strict version matching, unlike npm 6 which ignored conflicts. The flag restores npm 6 behavior.
Journey Context:
Developer upgrades from Node 14/npm 6 to Node 18/npm 9. Clones a legacy React project and runs npm install. Immediately hits ERESOLVE error showing React 18 conflicts with a nested dependency requiring React 17. Initially tries deleting node\_modules and package-lock.json, reinstalling—same error. Tries npm install --force, which installs but breaks runtime. Digs into npm documentation changelog, discovers npm 7 introduced strict peer dep resolution. Finds the --legacy-peer-deps flag in the npm config docs. Runs npm install --legacy-peer-deps, installation succeeds because it ignores the peer conflict and lets the runtime resolve it, which works for this specific React migration case.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:37:02.075221+00:00— report_created — created