npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.0.0" from some-library@2.1.0In one sentence: Two of your packages want different versions of the same dependency (usually React or Next.js), so npm refuses to install.
What it means
Many packages declare "peer dependencies": versions of React, Next.js or another library they expect you to already have. When one of your packages says it needs React 18 and your project uses React 19, npm stops and prints ERESOLVE instead of guessing.
This is very common in AI-built projects, because the AI picks the newest framework version but suggests a library that hasn't been updated for it yet. It also breaks Vercel and Netlify builds, which run a clean install.
Common causes
- A library only supports an older major version of React or Next.js than the one your project uses.
- The AI tool installed a package version that was written for a different framework version.
- Your lock file was created with a different npm version, or with `--legacy-peer-deps` locally but not on the build server.
How to fix it
- Read the 'Could not resolve dependency' and 'Conflicting peer dependency' lines: they name the package and the version it wants.
- Update that package to its latest version (`npm install some-library@latest`); newer versions usually support the newer framework.
- If there is no compatible version, either pick an alternative library or pin the framework to a version the library supports.
- As a temporary workaround, `npm install --legacy-peer-deps` installs anyway. If you use it, add `legacy-peer-deps=true` to a `.npmrc` file so Vercel builds the same way, and test the feature that uses that library.
Before
npm install some-library
# npm ERR! ERESOLVE unable to resolve dependency treeAfter
# 1) try a newer version first
npm install some-library@latest
# 2) last resort, and make the build server match:
echo "legacy-peer-deps=true" >> .npmrc
npm installTried this and it's still broken? Paste your exact error for a free explanation of your specific case.
Prompt to paste into your AI tool
npm install fails with ERESOLVE unable to resolve dependency tree. Here is the full error. Tell me which package conflicts with which version, whether a newer version of that package supports my React/Next.js version, and the safest fix. Only use --legacy-peer-deps if there's no compatible version, and explain the risk.Still stuck?
Paste your exact error and code. Get a plain-English explanation free, or the full fix for $5.
Hitting errors every day? Builder is $15/mo for 100 fixes per month. Compare plans
Related errors
- Error: listen EADDRINUSE: address already in use :::3000
- Stripe: No signatures found matching the expected signature for payload
- Next.js Image: hostname is not configured under images in next.config.js
- TypeError: Cannot read properties of undefined
Weekly: the errors breaking vibe-coded apps and how to fix them. Free.
No spam. Unsubscribe anytime.