npm ci ERESOLVE peer dependency conflict after upgrading to Node.js 20
Problem
npm ci fails with ERESOLVE on Node.js 20 for a project that installed cleanly on Node.js 18. No changes were made to package.json. npm 10 (shipped with Node.js 20) uses stricter peer dependency resolution by default. Legacy packages with broad peer dependency ranges that were previously ignored now cause hard errors.
Error Output
npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! While resolving: react-scripts@5.0.1 npm ERR! Found: react@18.3.1
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Add legacy-peer-deps=true to .npmrc or use package.json overrides
npm 10 (Node.js 20) uses strict peer dependency resolution. Packages with broad peer dependency ranges that were previously accepted now cause hard ERESOLVE errors.
Trust Score
5 verifications
- 1
Add legacy-peer-deps to .npmrc
Create or edit .npmrc in your project root:
textlegacy-peer-deps=true - 2
Or use overrides in package.json for specific conflicts
Force specific versions to resolve conflicts:
json{ "overrides": { "react": "^18.3.1", "react-dom": "^18.3.1" } } - 3
Delete node_modules and package-lock.json and reinstall
Clean install after the fix:
bashrm -rf node_modules package-lock.json && npm install
Validation
npm ci completes without ERESOLVE errors.
Verification Summary
Sign in to verify this fix
Environment
- Product
- npm
- Version
- 10.x
- Environment
- development
Submitted by
Alex Chen
2450 rep