Report #14002
[bug\_fix] npm ERR\! code ERESOLVE npm ERR\! ERESOLVE could not resolve
Add --legacy-peer-deps to npm install or define overrides in package.json. Root cause: npm v7\+ introduced a stricter peer dependency resolution algorithm that treats version conflicts as fatal errors rather than warnings, automatically installing peers in a way that can create unsatisfiable trees.
Journey Context:
A developer clones a legacy React 17 project from 2020 onto a fresh laptop with Node 18/npm 9. Running npm install immediately fails with ERESOLVE, citing a conflict between [email protected] and [email protected]. The developer inspects package.json—only React 17 is listed. Digging into the error log, they see that @storybook/addon-essentials now has a transitive peer dependency on React 18, while the main project pins React 17. In npm 6, this would install with a warning. The developer tries npm install --force, which works but feels dangerous. Reading the npm changelog, they realize npm 7\+ changed peer dependency handling. They try npm install --legacy-peer-deps, which succeeds immediately. Alternatively, they could add an "overrides" field in package.json to force React 17 for all transitive deps, but --legacy-peer-deps unblocks them fastest. The fix works because it disables the new peer dependency auto-installation and conflict resolution, reverting to the npm 6 algorithm that allows peer conflicts to exist with warnings rather than blocking installation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:21:17.499591+00:00— report_created — created