Fix npm ERESOLVE "unable to resolve dependency tree"

Quick answer: Getting npm ERR! ERESOLVE unable to resolve dependency tree in your Cursor, Bolt, or v0 project? Here's what peer dependency conflicts mean and how to fix them properly.

The error

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app@0.1.0
npm ERR! Found: react@19.0.0
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0 || ^17.0.0 || ^18.0.0" from some-library@2.3.1

(Newer npm versions print npm error instead of npm ERR!.)

Why it happens

Since npm 7, peer dependencies are installed and checked automatically. If a library declares it supports only certain versions of a peer (often react), and your project uses a different one, npm stops. This is very common in AI-generated projects, which mix the latest React/Next.js with libraries that haven't updated their peer ranges yet.

Fixes

1. Read the conflict

"Found" is what you have. "Could not resolve dependency: peer …" is what the library wants. Here: the project has React 19, but some-library@2.3.1 only lists up to React 18.

2. Upgrade the library (best fix)

npm view some-library peerDependencies   # check what the latest version supports
npm install some-library@latest

3. Or align your version

If the library has no compatible release, pin the peer to a supported version:

npm install react@18 react-dom@18

(Check that your framework supports it. For example, the Next.js App Router in Next 15 and 16 requires React 19, so downgrading React isn't an option there.)

4. Or override a nested peer (npm 8.3+)

// package.json
{
  "overrides": {
    "some-library": { "react": "$react" }
  }
}

$react means "use the version from my own dependencies". Test afterwards: the library may genuinely not work with that version.

5. Last resort: skip the peer check

npm install --legacy-peer-deps

This installs anyway, ignoring peer conflicts. To make Vercel do the same, add .npmrc:

legacy-peer-deps=true

Use it knowingly. It hides real incompatibilities. Prefer --legacy-peer-deps over --force.

6. Clean reinstall after changes

rm -rf node_modules && npm install

Only delete package-lock.json too if the install still fails. Deleting it re-resolves every package to its newest allowed version, which can introduce new breakages.

Prompt to paste into your AI tool

Here's my full ERESOLVE error: [paste]. Identify the conflicting package and peer, check whether a newer version supports my versions, and propose the smallest change. Don't use --force.

FAQ

Why did it work in Bolt/v0 but fail locally or on Vercel? Different npm versions or a missing lockfile mean the dependency tree is resolved differently. Does pnpm or yarn avoid this? They handle peers differently (often warnings rather than errors), but the underlying version mismatch is still there.

Still stuck? Paste your exact error into the free Error Fixer to get a plain-English cause, the fix, and a prompt to paste back into your AI tool.

Get the free "10 Prompts That Fix Broken AI Code" pack

Join the FixKit AI newsletter: one short email a week with real errors from Cursor, Lovable, Bolt & Replit users and how to fix them. Unsubscribe anytime.

Newsletter signup powered by beehiiv. We only use your email to send the newsletter.