npm ERR! code ERESOLVE 30-Second Fix Runbook — Diagnose by Copy-Pasting the Error Text
Got red text in the console, the build is stuck, and someone upstairs is asking when the deploy will land? We'll save the concepts for the bottom. First, find the exact phrase on your screen in the table below. One-second match → 30-second diagnosis → one-line copy-paste recovery.
1. Exact-match classification table for the error text
Find the line that actually printed in your console, as-is.
| Exact console text | Cause in one line | Go to |
|---|---|---|
npm ERR! code ERESOLVE / npm ERR! ERESOLVE unable to resolve dependency tree | npm 7+ couldn't reconcile the peer dependency tree. Header line for every conflict | §2 decision tree |
npm ERR! Could not resolve dependency: peer react@"^17.0.0" from some-lib@x.x.x | some-lib wants react 17, but you installed 18/19 | Extract the package and required version from this line → §4 |
npm ERR! Conflicting peer dependency: | Two different packages require incompatible peer ranges | Pin with overrides (§4-2) |
npm WARN ERESOLVE overriding peer dependency | Not an error. Optional peer warning. Install still succeeds | Ignore and continue |
npm ERR! Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps | Workaround hint from npm. Check the risk before following it | Must-read: comparison table in §4-1 |
The most important lines are Could not resolve dependency: and Conflicting peer dependency:. They contain the conflicting package name and the required version.
2. 30-second decision tree
Start by checking your npm version.
npm -vnpm below 7 (6.x) → ERESOLVE almost never appears. (If you're seeing this error, 99% chance you're on npm 7+)
npm 7+ → auto-installs peer deps + strict checks. That's the cause.
↓
Find the conflict line in the error message:
"Could not resolve dependency: peer X@\"range\" from Y"
→ conflicting package = Y, problem peer = X, required version = range
↓
┌───────────────┴───────────────┐
① Demo / urgent build ② Production / long-term maintenance
"Just make it run" "The next person must get the same install"
↓ ↓
§3: legacy-peer-deps §4: pin versions with overridesOne-line summary: Work around if you're in a hurry; pin if you want it done right. A workaround is never a root-cause fix.
3. Just make it run — legacy-peer-deps vs force comparison
These two flags get the install through right now. If you reach for --force without knowing the difference, you'll have a bigger incident next week.
npm install --legacy-peer-deps | npm install --force | |
|---|---|---|
| Behavior | Ignores peer checks the way npm 6 did | Forcibly ignores every conflict + overwrites the cache |
| Risk | Medium (skips peers only) | High (can install unintended versions) |
| When to use | Temporary workaround for a single peer conflict | Last resort |
# 단일 peer 충돌, 일단 빌드만 돌리고 싶을 때
npm install --legacy-peer-deps
# 최후의 수단 (무엇이 깔릴지 보장 안 됨)
npm install --forceIf you don't want to type the flag every time, you can bake it into the project.
# .npmrc
legacy-peer-deps=true⚠️ Neither is a root-cause fix. The peer conflict is still there, and a different version can land on a teammate's machine or in CI. For production, go to §4 and pin the version with
overrides.
4. Fix it properly — version-pinning runbook with overrides
4-1. Trace who requires the conflicting peer
# 예: react 버전 충돌이면
npm ls reactmy-app@1.0.0
├── react@18.3.1
└─┬ some-old-lib@2.1.0
└── react@"^17.0.0" ← this is the culpritThis shows you immediately, as a tree, which package is asking for the old version.
4-2. Force-pin with package.json overrides (npm 8.3+)
This pins even transitive dependencies to a specific version.
{
"overrides": {
"react": "18.3.1",
// nest if you only want to change react under a specific package
"some-old-lib": {
"react": "18.3.1"
}
}
}Yarn does the same thing with resolutions.
// yarn (package.json)
{
"resolutions": {
"react": "18.3.1"
}
}After applying, wipe the lockfile and node_modules clean and reinstall for it to take effect.
rm -rf node_modules package-lock.json
npm install4-3. If that still fails, clean the cache too
npm cache clean --force
rm -rf node_modules package-lock.json
npm installA note from the trenches: You hit this pattern constantly during React 18→19 migrations. When an old UI library insists on peer react@"^17", we opened an upgrade PR for the library, and until it merged we pinned react with overrides so the whole team installed the same version. Projects that just stuck --legacy-peer-deps in and moved on got a slightly different version in CI a few weeks later and hit "it worked on my machine" twice.
5. yarn / pnpm use different commands
The same peer conflict needs different hands depending on the package manager.
| Task | npm | yarn | pnpm |
|---|---|---|---|
| Force-pin version | overrides (package.json) | resolutions (package.json) | pnpm.overrides (package.json) |
| Bypass peer checks | --legacy-peer-deps | Loose by default | --no-strict-peer-dependencies |
| Reinstall | rm -rf node_modules package-lock.json && npm install | rm -rf node_modules yarn.lock && yarn | rm -rf node_modules pnpm-lock.yaml && pnpm i |
pnpm example:
// package.json
{
"pnpm": {
"overrides": {
"react": "18.3.1"
}
}
}pnpm defaults to a strict peer policy, so conflicts surface more readily than with npm. In a pinch, work around with pnpm install --no-strict-peer-dependencies—again, that's temporary.
6. Recurrence-prevention checklist
If you never want to see this red text again, bake the following in.
1) Pin versions (package.json)
{
"engines": {
"node": ">=20.0.0",
"npm": ">=10.0.0"
}
}2) Unify the Node version (.nvmrc)
20.11.03) In CI, use ci, not install
# install: can update the lockfile (breaks reproducibility)
# ci: reproduces the lockfile exactly; fails immediately on mismatch
npm cinpm ci reproduces package-lock.json 100% as-is, so it stops "works locally, fails in CI."
Copy-paste command cheat sheet
npm -v # 1) check version (ERESOLVE is expected on 7+)
npm ls <package-name> # 2) trace the conflicting culprit
npm install --legacy-peer-deps # 3) temporary workaround if you're in a hurry
# after adding overrides to package.json ↓ # 4) root-cause fix
rm -rf node_modules package-lock.json
npm install
npm cache clean --force # 5) if that still fails, cache tooReferences: official docs
The primary sources for the behavior, settings, and errors covered in this post are the official docs below. Check them for version-specific options and exact behavior.
FAQ
Q. Should I use --legacy-peer-deps or --force?
A. Use --legacy-peer-deps if you only need a short workaround for a single peer conflict. --force overwrites every conflict and can install unintended versions—last resort only. Neither is a root-cause fix, so for production pin the version with overrides.
Q. Do I need to fix npm WARN ERESOLVE overriding peer dependency?
A. No. WARN is not an error—it's an optional peer warning. The install completes normally and the build does not stop. You can ignore it and continue.
Q. I added overrides but they aren't taking effect.
A. That's the lockfile cache. Delete with rm -rf node_modules package-lock.json, then npm install again for it to apply. Also check that you're on npm 8.3+ (npm -v). Older versions don't support overrides.
Nodelog는 모든 콘텐츠의 내용과 출처를 공개 전에 검토합니다. 환경(OS·버전)에 따라 결과가 달라질 수 있는 기술 정보는 공식 문서와 함께 확인하며, 검토 기준과 정정 원칙은 편집 정책에서 안내합니다. 오류를 발견하시면 이메일로 제보해 주세요 — 확인 후 신속히 정정합니다.
Comments
Be the first to comment.