Skip to content
VibecodeZero

npm ERR! ERESOLVE unable to resolve dependency tree: what it means and how to fix it

Updated

On this page (4)
  1. Symptom
  2. Cause
  3. Prompt to paste
  4. How not to burn credits

Symptom

npm install, or a command like npm install some-package, stops with npm ERR! code ERESOLVE and npm ERR! ERESOLVE unable to resolve dependency tree (newer npm versions write npm error instead of npm ERR!). Below it there are lines like Found: react@19.x, Could not resolve dependency: peer react@"^18.0.0" from some-package, and a suggestion to retry with --force or --legacy-peer-deps. Sometimes the same error shows up in the build log when you publish.

Cause

Your app is built from packages other people wrote. Many of them depend on a main package being there already, most often React. Instead of bringing their own copy, they say which versions they work with. That’s a peer dependency.

When you run npm install, npm puts together one list of versions that has to satisfy every package at once. Since npm 7 it also checks peer dependencies. If one package says “React 18 only” and your project has React 19, there’s no version that makes both happy, and npm stops with ERESOLVE.

It usually shows up:

  • right after the AI adds a new package, like a date picker, a chart library or a UI kit, that hasn’t caught up with the version of React or Next.js your project uses;
  • when you download a project from Bolt, Lovable or v0, or clone it from GitHub, and run npm install on your computer;
  • when your hosting installs the packages to publish the app.

It’s not a bug in your code. Nothing in your app runs during this error. It’s a disagreement between packages.

How to read it

The output is long, but two lines matter:

npm ERR! Found: react@19.1.0
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.0.0" from some-package@2.0.0

Found is what your project has. Could not resolve dependency names the package that wants something else (some-package, version 2.0.0) and what it wants (^18.0.0, meaning React 18.x). On newer npm versions each line starts with npm error instead of npm ERR!. The numbers above are an example: yours will be different.

Beginner steps

  1. Find the two packages. Copy the Found line and the Could not resolve dependency line. Write down the package name that disagrees.
  2. Check if a newer version fits. Run npm view some-package peerDependencies, with the real name. It shows what the latest version of that package accepts. If it includes your version, install it with npm install some-package@latest.
  3. Undo the last package, if it caused this. If the error started when the AI added a package, go back to the version before that change, or remove it with npm uninstall some-package. Then ask the AI for the same feature with a package that supports your versions.
  4. Ask before changing main packages. If the AI wants to downgrade React or Next.js to make one package fit, ask why first. That can break other parts of the app.
  5. Workaround, only if needed. npm install --legacy-peer-deps finishes the install by skipping the check. Then test every part of the app that uses that package. Your hosting will fail the same way unless the project has a .npmrc file with legacy-peer-deps=true.
  6. Avoid --force unless someone who codes has looked at the conflict. It turns off more checks than the conflict needs.

If you’re stuck, paste the prompt on this page with the whole error, and ask the AI to explain the conflict before it changes anything.

If npm itself isn’t found, start with npm is not recognized or command not found. Once the install works, the next error may be Cannot find module, which also explains how to check that a package the AI suggested is real. If the app starts but the port is taken, see Port 3000 is already in use. If the AI keeps changing versions back and forth, read The AI says it fixed it, but the error is still there.

Prompt to paste

Copy the text below, replace what’s in brackets and send it in the chat of the tool you’re using.

Paste into the AI
npm install fails with an ERESOLVE error. Here is the whole output:
[paste the whole error, from npm ERR! code ERESOLVE to the end]

It happened when: [I ran npm install / I asked you to add a package / I published].
The last package added was: [the package name, if you know it].

First, without changing anything, explain in plain words which two packages disagree and about which version. Use the Found line and the Could not resolve dependency line.
Then suggest the smallest fix: a version of the package that disagrees that supports the version I already have. Show me how you checked that, for example with npm view [package] peerDependencies.
Don't use --force. Don't upgrade or downgrade React, Next.js or other main packages without asking me first. Don't delete package-lock.json or rewrite package.json beyond the one change.
If the only way forward is --legacy-peer-deps, say so, explain the risk, and tell me what to test afterwards.

How not to burn credits

  • Before you ask the AI, read the Found and Could not resolve dependency lines yourself. Paste the whole error once, in one message, instead of describing it.
  • If the error started right after the AI added a package, the quickest fix is often to undo that change and ask for the feature again, telling the AI which versions you have.
  • If the AI answers every attempt with --force, or swaps package versions back and forth, stop. Ask it to explain the conflict first, without changing files.
  • Don't delete the lock file to make the error go away. It can change many versions at once and create new problems, while the conflict is still there.

How Lovable counts credits, and what the free plan includes: Lovable credits explained.

Questions people ask

What does ERESOLVE unable to resolve dependency tree mean?

npm tried to work out a set of package versions that all fit together and couldn't. One package needs a version of something, usually React, that's different from the one your project has. Instead of picking one and hoping, npm stops and shows you the conflict.

What is a peer dependency?

It's a package saying which version of another package it expects you to already have. A React component library, for example, doesn't bring its own React. It says "I work with React 18" and uses yours. If your project has React 19 and the library only lists React 18, npm sees a conflict.

How do I read the error?

Look for two lines. Found: react@19.1.0 is what your project has. Could not resolve dependency: peer react@"^18.0.0" from some-package@2.0.0 is the package that wants something else. The ^18.0.0 means version 18 or a newer 18.x version, so 19 doesn't fit.

What does --legacy-peer-deps do?

It tells npm to ignore peer dependencies while installing, the way npm 6 and older did. The install finishes, but npm doesn't check that the versions fit. Many packages work anyway, but some break in ways that only show up when you use the app. Treat it as a workaround, test the parts of the app that use that package, and look for a real fix.

Is --force the same as --legacy-peer-deps?

No. --force still tries to install peer dependencies but accepts conflicting versions, and it also turns off other safety checks npm normally runs. It's the bluntest option. npm's own error message says both flags mean accepting an incorrect (and potentially broken) dependency resolution. Prefer fixing the versions.

It installs on my computer with the flag, but fails when I publish. Why?

The flag only applied to the command you typed. Your hosting runs its own npm install without it, so it hits the same conflict. Fixing the versions solves it everywhere. If you really need the workaround, a file called .npmrc in the project folder with the line legacy-peer-deps=true makes npm use it on every install, including the hosting's, but the conflict is still there.

Does this happen in Lovable, Bolt, v0 or Replit?

It can happen anywhere npm installs packages, but you mostly see it when you run a project on your own computer, in Cursor or Claude Code, or in a project downloaded from one of these tools. In a browser builder, it can show up in the install or build log after the AI adds a package. The fix is the same: find the two packages that disagree.

New guides by email. An email when we publish a new guide, error fix or chapter, in plain English. Subscribe