Report #85948
[bug\_fix] npm ERR\! code ERESOLVE
Add --legacy-peer-deps to npm install \(e.g., npm install --legacy-peer-deps\) or manually align conflicting peer dependency versions in package.json. Root cause: npm 7\+ enforces strict peer dependency resolution \(RFC 25\), breaking installs where packages declare incompatible peer ranges.
Journey Context:
You clone a legacy React 17 project and run npm install. Instead of success, you see ERESOLVE with a dependency tree showing [email protected] conflicts with react@^18.0.0 required by a devDependency. You try deleting package-lock.json and node\_modules, but the error persists. You attempt --force, which installs packages but then your build fails with 'Invalid hook call' because multiple React versions exist. Debugging reveals npm 7\+ changed peer dependency handling via RFC 25. The flag --legacy-peer-deps restores npm 6 behavior where peer conflicts are warnings, not fatal errors, allowing the install to proceed while you plan the actual migration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:51:09.182022+00:00— report_created — created