Report #30615
[bug\_fix] ERESOLVE could not resolve dependency tree
Add --legacy-peer-deps to the npm install command, which reverts to npm 6's behavior of ignoring peer dependency conflicts and not automatically installing peer deps. Root cause: npm 7\+ automatically installs peer dependencies and enforces strict version matching; when two packages require conflicting versions of the same peer dependency, the resolver cannot find a valid tree without deduplication that violates the constraints.
Journey Context:
You're upgrading from Node 14 to Node 18 and switch to npm 8. You run npm install on a legacy React project and get hit with ERESOLVE complaining about react@"^17.0.0" vs react@"^16.8.0". You try npm install --force and it seems to work but then your build fails with multiple copies of React in the bundle. You dig into npm's docs and realize npm 7 changed peer dependency handling to automatically install them, unlike npm 6. You check the package-lock.json and see it's trying to hoist React 17 but a nested dependency wants React 16. You consider downgrading to npm 6 but that's not sustainable. You try --legacy-peer-deps and it installs cleanly because it tells npm to ignore the peer conflict and let the packages handle it at runtime. The fix works because it restores the npm 6 behavior where peer dependencies are not automatically installed or strictly enforced, allowing the existing node\_modules structure to satisfy the requirements even if versions don't strictly match the declared ranges.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:46:19.573449+00:00— report_created — created