Fix guides · Cursor, v0, Lovable, Bolt, Claude Code, Replit ·

Fix npm ERESOLVE unable to resolve dependency tree

npm ERR! ERESOLVE unable to resolve dependency tree

npm refuses to install because two packages need incompatible versions of the same dependency. The classic case: your app uses React 19 (or Next.js 15+) but a component library like react-beautiful-dnd or an older UI kit declares peerDependencies on React ^16 || ^17 || ^18. npm's default strict peer dependency check cannot pick a single React version that satisfies both. Fix by updating the peer-restricted package, using --legacy-peer-deps for a one-off install, or pinning the shared dependency to a version both accept.

Free · 3 a day · no signup

Common causes – and how to tell which one you have

1. React version newer than the library's peer range

How to tell: The error shows Found: react@19.x.x and peer react@^16.8.5 || ^17.0.0 || ^18.0.0 from a library like react-beautiful-dnd (unmaintained, no React 19 release), react-dnd, or an older UI kit. Your package.json likely has react@^19 or next@15+ which pulls React 19.

Fix: First try upgrading the library to its latest version (npm install <library>@latest). If it now supports React 19, the conflict disappears. If the library is unmaintained and has no React 19 release (like react-beautiful-dnd), switch to a maintained alternative (e.g., @hello-pangea/dnd for drag-and-drop), or use --legacy-peer-deps, or pin React to 18.3.1 if you are not on Next.js 15.

2. Multiple packages demand different versions of the same peer

How to tell: The error lists two or more packages with non-overlapping peer ranges for the same dependency, e.g., package-a wants react@^17 and package-b wants react@^18.

Fix: Upgrade the more restrictive package, or if both are maintained, pin React to the highest version that satisfies both (e.g., react@18). Use npm overrides if the conflict is transitive.

3. Transitive dependency conflict from a framework template

How to tell: You created the app with a starter (create-next-app, create-vite, etc.) and the template's lockfile or dependencies include an old library. The error appears on first install or after adding a new package.

Fix: Run npm install --legacy-peer-deps once to get a working tree, then upgrade or replace the offending library. Add --legacy-peer-deps to your CI script if the deploy host runs a clean install.

How to fix it

  1. Run npm install and copy the full error. It shows the conflicting package (e.g., react-beautiful-dnd@13.1.1), the peer range it demands (peer react@^16.8.5 || ^17.0.0 || ^18.0.0), and what is actually at the top level (Found: react@19.0.0).
  2. Check if the conflicting package has a newer version that supports React 19. Run npm view <package>@latest peerDependencies and see if react@19 is included. If yes, upgrade that package: npm install <package>@latest. If the library is unmaintained (e.g., react-beautiful-dnd has no React 19 release), look for a maintained replacement such as @hello-pangea/dnd, or skip to the next step.
  3. If no update exists, install with --legacy-peer-deps to bypass the check for this install: npm install --legacy-peer-deps. Add it to your CI/build script if the deploy host runs npm install.
  4. Alternatively, pin React to the highest version the peer range accepts (e.g., npm install react@18.3.1 react-dom@18.3.1). Warning: if you are on Next.js 15 (App Router), it requires React 19 — pinning React 18 will break the app. Only do this if you are not on Next.js 15+.
  5. If the conflict is in a transitive dependency (a dependency of a dependency), add an overrides entry in package.json: "overrides": { "react": "18.3.1" } (for npm 8.3+). For pnpm, use "pnpm": { "overrides": { "react": "18.3.1" } } in package.json; for yarn, use "resolutions": { "react": "18.3.1" }.
  6. Run npm install again (with --legacy-peer-deps if needed) and confirm the lockfile updates. Commit the lockfile.
  7. Run your build and tests to ensure nothing breaks from the version change.

Using Lovable, Bolt or v0?

In Bolt or v0, tell the AI: "npm install fails with ERESOLVE. Check if the conflicting package has a React 19 compatible version. If yes, upgrade it. If not, add --legacy-peer-deps to the install command and pin React 18 temporarily." Then check the build log on your host (Vercel, Netlify) — if it runs npm ci, add --legacy-peer-deps there too.

Using Cursor, Claude Code or Windsurf?

Ask Cursor or Claude Code to run npm install, capture the full ERESOLVE error, identify the exact package and peer range, check npm view <package>@latest peerDependencies, and propose the least invasive fix. Have it run the install again with the fix and confirm the build passes.

The “fix” to avoid

Agents often delete package-lock.json and node_modules and retry, which just re-downloads the same conflict. Others edit node_modules directly or use npm install --force (which ignores all peer checks and can leave broken trees). Use --legacy-peer-deps for a controlled bypass, or fix the version mismatch properly.

Copy-paste fix prompt for your AI coding tool

Paste this into Cursor, Claude Code, Lovable or Bolt:

npm install fails with "ERESOLVE unable to resolve dependency tree". The error shows: Found: react@19, peer react@^16.8.0 || ^17.0.0 || ^18.0.0 from react-beautiful-dnd@13.1.1 (or similar). Check in order: 1) Does the conflicting package have a newer version supporting React 19? Upgrade it. 2) If not, can we pin React to 18.3.1 temporarily? 3) If neither works, add --legacy-peer-deps to the install command (CI and local). 4) As a last resort, use npm overrides to force the version. Do not delete package-lock.json or node_modules as a first step. Tell me which approach you chose and verify npm install completes and the build passes.
Your error looks a bit different? Paste your exact error and get a diagnosis tailored to your code — free.

Questions people ask

What does --legacy-peer-deps actually do?

It tells npm to skip peer dependency validation during install, using the pre-npm v7 behavior. The install succeeds, but you must verify the app works — peer deps exist for a reason (API compatibility).

Should I use npm overrides to force React 18?

Overrides are a blunt tool that can break other packages expecting React 19. Prefer upgrading the conflicting library or pinning React explicitly in your dependencies. Use overrides only for transitive conflicts you can't fix otherwise.

Why did this start after upgrading Next.js?

Next.js 15+ uses React 19. Your existing component libraries may not have updated their peerDependencies yet. The conflict is between the new framework and the old library.

Official documentation

Related errors

Get fixes like this every week