Report #97694
[bug\_fix] npm ERR\! ERESOLVE could not resolve dependency tree
Add \`--legacy-peer-deps\` flag to the npm install command, or use \`npm install --legacy-peer-deps\`.
Journey Context:
I was setting up a React project with npm v7\+ and tried to install a package \(like react@17\) alongside an existing dependency that required a different peer version of react \(e.g., react@18\). npm's strict peer dependency resolution in v7 immediately threw ERESOLVE, refusing to install. I spent an hour checking package.json versions, clearing node\_modules, and even trying \`--force\`, which worked but felt wrong. After reading the npm docs, I learned that v7 changed peer dependency handling from a warning to a hard error. The \`--legacy-peer-deps\` flag reverts to npm v6's behavior, allowing the install to proceed with warnings instead of blocking. This is the standard fix for legacy projects or when you cannot update all dependencies to match peer requirements.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:52:23.069359+00:00— report_created — created