Report #100519
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree
Use \`--legacy-peer-deps\` as a one-off install flag, or permanently set \`legacy-peer-deps=true\` in \`.npmrc\`. The real fix is either to align the installed package's peerDependency requirements with the installed version of React/etc., or to use overrides/resolutions. Do not blindly use --force; it masks the conflict rather than resolving it.
Journey Context:
You run \`npm install some-ui-lib\` in a project on React 18 and npm vomits \`ERESOLVE unable to resolve dependency tree\` saying \`[email protected]\` wants \`react@^17.0.0\`. You check \`node\_modules\` and React 18 is there. The rabbit-hole: npm v7\+ changed the resolver to install peer deps automatically and treat peer-dependency conflicts as hard errors instead of warnings. You try deleting \`node\_modules\` and \`package-lock.json\`; same error. You look at the library's repo and find an open issue asking for React 18 support. You consider downgrading React, but that's destructive. Then you remember npm added \`legacy-peer-deps\` to restore the pre-v7 behavior where peer conflicts are warnings. You run \`npm install some-ui-lib --legacy-peer-deps\`, the install succeeds, the app still works because the library is compatible with React 18 in practice, and you pin the flag in \`.npmrc\` so CI uses it too. If you own the library, the proper fix is widening the peerDependency range and releasing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:39:02.424259+00:00— report_created — created