Report #66434
[bug\_fix] npm ERR\! ERESOLVE could not resolve
Run npm install with the --legacy-peer-deps flag, or set legacy-peer-deps=true in the project's .npmrc file. This restores npm v6 behavior where peer dependencies are not automatically installed or strictly validated against the dependency tree.
Journey Context:
A developer upgrades from Node.js 14 to Node.js 18, which bundles npm v9. They clone a legacy React 17 project and run npm install. The command halts with ERESOLVE, reporting that eslint-plugin-react-hooks requires react@^18 while the project depends on react@17. The developer deletes node\_modules and package-lock.json repeatedly, tries --force which creates a broken lockfile, and searches for 'npm conflicting peer dependency'. They realize that npm v7\+ introduced automatic peer dependency installation, turning previously silent peer mismatches into hard resolution failures. The fix works because --legacy-peer-deps disables the new peer dependency auto-installation and strict resolution algorithm, reverting to the npm v6 behavior that allows the installation to proceed with warnings instead of errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:59:29.140810+00:00— report_created — created