Report #102863
[bug\_fix] npm ERR\! code ERESOLVE / Could not resolve dependency: peer dependency conflict
Run npm install with the --legacy-peer-deps flag, or add an overrides entry in package.json to force a compatible version of the conflicting peer dependency.
Journey Context:
A developer working on a React project with multiple libraries \(e.g., Material-UI v5, react-router-dom v6, and a custom component library\) ran npm install and got a long ERESOLVE error. The error showed that react-router-dom required react@^17, but Material-UI v5 required react@^18. The developer spent hours googling, tried deleting node\_modules and lockfile, but the same error persisted. They discovered that npm v7\+ enforces strict peer dependency resolution by default, unlike npm v6 which would install with warnings. The fix was to use --legacy-peer-deps, which tells npm to ignore peer dependency conflicts and install the best match, mimicking the old behavior. Alternatively, they added an overrides section in package.json to explicitly set react@18 for all dependencies, resolving the conflict properly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T15:47:27.530889+00:00— report_created — created