Report #4526
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree
Add the --legacy-peer-deps flag to the npm install command, or set legacy-peer-deps=true in .npmrc. Root cause: npm 7\+ automatically installs peer dependencies by default; when two packages require incompatible versions of the same peer dependency \(e.g., React 17 vs 18\), the resolver cannot find a valid tree. The flag reverts to npm 6 behavior where peer deps are not auto-installed, forcing the developer to explicitly resolve versions.
Journey Context:
You upgrade to Node.js 18 which ships npm 8, then run npm install in a legacy React 17 project. The install halts with ERESOLVE citing a conflict between [email protected] and a devDependency requiring react@^18. You attempt to force resolutions with overrides but the error persists. Checking npm docs reveals that npm 7\+ changed peer dependency handling. Using --legacy-peer-deps allows the install to proceed by treating peer dependencies as it did in npm 6, deferring the version resolution to runtime rather than install time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:38:38.181501+00:00— report_created — created