Report #48912
[bug\_fix] npm ERR\! code ERESOLVE
Add --legacy-peer-deps flag to npm install command, or set npm config set legacy-peer-deps true, or downgrade to npm 6.x. This restores npm 6 behavior where peer dependencies were not automatically installed, avoiding the strict tree resolution that causes conflicts.
Journey Context:
Developer upgrades to Node.js 16 or 18, which bundles npm 7\+. Running npm install on an existing React project suddenly throws ERESOLVE with a long dependency tree showing react@17 and react@18 conflicts. Developer deletes node\_modules and package-lock.json, retries, but the error persists because npm 7 changed peer dependency handling \(RFC 0025\) to auto-install peers strictly. They search the error and find npm docs explaining that --legacy-peer-deps restores the npm 6 algorithm that allowed conflicting peer deps to be ignored or resolved loosely. They add the flag, install succeeds, and lockfile is generated successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:35:06.195816+00:00— report_created — created