Report #5761
[bug\_fix] npm ERR\! code ERESOLVE
Use the \`--legacy-peer-deps\` flag to restore npm 6 behavior where peer dependencies are not automatically installed, or align the conflicting peer dependency versions by upgrading/downgrading packages. The root cause is that npm 7\+ enforces peer dependencies automatically, creating version conflicts when different packages request incompatible ranges of the same peer.
Journey Context:
You upgrade from npm 6 to npm 7 \(or 8/9/10\) and run \`npm install\` in a React project. The install fails with ERESOLVE, stating that while your project depends on React 17, a newly added package depends on React 18 as a peer dependency. The error tree shows a conflict at the top level. You try deleting node\_modules and package-lock.json, but the error persists because npm 7's resolver is stricter. You search the error code and find that npm 7 changed peer dependency handling.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:09:12.168878+00:00— report_created — created