ERESOLVE unable to resolve dependency tree
npm stopped installing because a package only supports a different version of something your project already uses, most often React.
Also appears as
- npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree
- npm error code ERESOLVE npm error ERESOLVE could not resolve
- npm warn ERESOLVE overriding peer dependency
Prompt to fix it
npm install fails with "ERESOLVE unable to resolve dependency tree". Read the Found and Could not resolve dependency lines and tell me which package conflicts with which version. Check whether a newer version of that package supports our versions, and upgrade it. If it’s unmaintained, suggest a maintained replacement and update the code that uses it. Don’t use --force, and only use --legacy-peer-deps if there’s no other option, after telling me the risk. Make sure a clean npm install works afterward.
Paste into Layerwise or any AI coding tool.
What it means
Some packages declare peer dependencies: other packages they expect you to install, in a version range they support. Since npm 7, npm install enforces those ranges, and this error means no single version satisfies everyone. Read it in two parts: Found is what your project uses, and Could not resolve dependency names the package whose range leaves it out.
Here, the app uses React 19, and react-beautiful-dnd only lists React 16 to 18. That happens a lot with AI-generated code: the tool picks a well-known package from its training data, and that package stopped getting updates before the current React or Next.js came out.
npm suggests --force or --legacy-peer-deps. Both finish the install by ignoring the conflict, and the package may then crash or misbehave at runtime. A legacy-peer-deps=true line in .npmrc does the same for every install, often without anyone noticing. Use them only as a last resort, after you’ve tested the package with your versions. A newer release or a maintained replacement fixes it properly.
Common causes
- The code uses a package whose latest release doesn’t list your React or Next.js version as supported.
- A core package was upgraded, such as React 18 to 19, while related packages like a UI kit or testing library stayed on old releases.
- Two packages need different major versions of the same peer, such as plugins built for different ESLint versions.
- The project was installed locally with
--legacy-peer-deps, and the server’s cleannpm installapplies npm’s strict rules.
How to fix it
- Read the
Could not resolve dependencyblock. It names the package and the version range it accepts. - Check that package for a newer release that supports your versions, using
npm view <name> peerDependencies, and install it withnpm install <name>@latest. - If the package is unmaintained, switch to a maintained replacement, such as
@hello-pangea/dndforreact-beautiful-dnd, and update the code that uses it. - If an upgrade caused it, upgrade the related packages at the same time, or pin the shared package to a version every package accepts.
- As a last resort, install with
--legacy-peer-depsafter testing that the package works with your versions. Putlegacy-peer-deps=truein.npmrcso the server installs the same way, and remove it once the package catches up.
Example fix
# Which React versions does each package accept?
npm view react-beautiful-dnd peerDependencies
npm view @hello-pangea/dnd peerDependencies
# Swap in the maintained fork, then install normally.
npm uninstall react-beautiful-dnd
npm install @hello-pangea/dndRelated errors
All errorsInvalid hook call
A hook such as useState ran somewhere React can’t track it, or the app loaded two copies of React that don’t know about each other.
vite: command not found
The shell couldn’t find the vite program, almost always because the project’s packages aren’t installed or the command ran in the wrong folder.
Command "npm run build" exited with 1
Your build script failed on the host. This line only reports the failure; the actual error is printed earlier in the build log.
Cannot find module
Node tried to load a package or file that isn’t where the code says it is, usually because it was never installed or the path is wrong.
Build with an agent that checks its work
The Layerwise agent clicks through the live preview and reads the console, so it catches errors before you do.