Report #42567
[bug\_fix] npm ERR\! code ERESOLVE
Run \`npm install --legacy-peer-deps\` to restore npm 6.x behavior where peer dependencies are not automatically installed, or manually align all transitive peer dependency versions to a single compatible range.
Journey Context:
Developer upgrades a React 17 project by running \`npm install react@18\`. The terminal fills with an ERESOLVE error showing a dependency tree where a transitive library \(e.g., an old UI kit\) depends on React 17 as a peer. Trying \`--force\` installs the packages but causes runtime 'Invalid hook call' errors due to multiple React instances. Debugging reveals that npm 7\+ automatically installs peer dependencies, attempting to satisfy both React 17 and 18 simultaneously, which is impossible. The developer realizes \`--legacy-peer-deps\` tells npm to ignore peer dependency auto-installation, reverting to npm 6 behavior where conflicts are just warnings, allowing manual resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:55:06.586546+00:00— report_created — created