Report #52265
[bug\_fix] npm ERR\! code ERESOLVE: unable to resolve dependency tree due to peer dependency conflict \(e.g., 'Found: [email protected]', 'Could not resolve dependency: peer react@^17.0.0'\)
Run npm install with the --legacy-peer-deps flag, or set legacy-peer-deps=true in .npmrc. Root cause: npm v7\+ uses the Arborist resolution engine which strictly enforces peer dependency trees, treating conflicts as hard errors rather than warnings like npm v6.
Journey Context:
You upgrade from Node 14/npm 6 to Node 18/npm 8 and npm install suddenly fails on a package that worked yesterday. The error ERESOLVE lists conflicting peer dependencies, typically React versions. You delete node\_modules and package-lock.json, but it still fails. You search and find suggestions to use --force, but that feels wrong. You realize npm v7 introduced strict peer dependency resolution where packages can only access explicit peer dependencies, not hoisted ones. The fix is using --legacy-peer-deps to revert to npm v6's lenient peer resolution behavior, explicitly telling the Arborist engine to ignore peer conflicts. After adding the flag, install succeeds because the resolver treats peer mismatches as warnings rather than blocking errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:13:16.019233+00:00— report_created — created