Report #15518
[bug\_fix] npm ERR\! code ERESOLVE npm ERR\! ERESOLVE could not resolve npm ERR\! Found: [email protected] npm ERR\! Could not resolve dependency: npm ERR\! peer react@"^18.0.0" from [email protected]
Add the \`--legacy-peer-deps\` flag to the npm install command, or set \`legacy-peer-deps=true\` in .npmrc. This restores npm 6's peer dependency resolution behavior where conflicts produce warnings rather than blocking errors. The root cause is npm 7\+'s stricter peer dependency tree validation that treats mismatched peer requirements as unresolvable conflicts rather than warnings.
Journey Context:
A developer upgrades from Node.js 14/npm 6 to Node.js 18/npm 8 and attempts to install a legacy React 17 project alongside a newer library requiring React 18. The install fails with ERESOLVE, presenting a dependency tree showing a peer conflict. The developer initially tries deleting node\_modules and package-lock.json, then using \`npm cache clean --force\`, but the error persists because the conflict is structural in the dependency requirements. They search the error code and find references to npm 7's peer dependency strictness. They try \`--force\` which works but feels unsafe. Eventually they discover \`--legacy-peer-deps\` which specifically relaxes the peer dependency resolution without bypassing other security checks, allowing the install to proceed while logging warnings about potential runtime incompatibilities.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:20:19.779632+00:00— report_created — created