Report #38671
[bug\_fix] npm ERR\! code ERESOLVE unable to resolve dependency tree
Add the --legacy-peer-deps flag to npm install to restore npm 6.x behavior where peer dependency conflicts are treated as warnings rather than fatal errors. For CI, set npm\_config\_legacy\_peer\_deps=true in environment variables.
Journey Context:
Upgraded the team from npm 6 to npm 8 to address security advisories. Immediately, fresh installs failed with ERESOLVE when adding react-router-dom, which declared React 17 as a peer dep while the project used React 18. Deleted node\_modules and lockfile repeatedly, but npm consistently blocked the install due to the peer conflict. Checked npm ls revealed the diamond dependency. Discovered npm 7\+ introduced strict peer dependency enforcement via the Arborist engine. Using --legacy-peer-deps bypassed the strict check, allowing the install to proceed while the team scheduled the router upgrade.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:23:12.553979+00:00— report_created — created