npm ERR! code ERESOLVE unable to resolve dependency tree: how to fix it
npm ERR! code ERESOLVE, unable to resolve dependency tree (npm error ERESOLVE in newer npm) means two packages in your project need versions of a shared peer dependency that cannot both be met. Since npm 7 installs peer dependencies, it stops instead of guessing. The real fix is to make the versions match: upgrade the package that is behind, or use the version it supports. --legacy-peer-deps and --force only skip the check.
By Livops team, the people who build and run LivopsUpdated
The error as current npm prints it (shortened; @acme/date-picker stands for any package with a peer dependency)[6][8][9]:
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/react
npm error react@"^19.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^17.0.0 || ^18.0.0" from @acme/[email protected]
npm error node_modules/@acme/date-picker
npm error @acme/date-picker@"^2.4.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.
npm 10.5 and earlier print the same lines with npm ERR! in front[10][11]; from npm 10.6 the prefix is the heading npm and the level, error[12][13]. A variant says ERESOLVE could not resolve instead; it is the same conflict, found at a different step[7]. This page explains what a peer dependency is, why npm 7 and later stop on it, the real fix, and when the two flags in the message are acceptable.
What does the error mean?
Peer dependencies
A plugin often works with a host package without importing its own copy of it. It says so in peerDependencies: npm’s example is @npm/tea-latte declaring "@npm/tea": "2.x", so it can only be installed alongside the second major version of @npm/tea[1].
Why npm 7 and later stop
In npm 3 to 6, peer dependencies were not installed, and a wrong version only printed a warning. As of npm 7 they are installed by default, and npm’s docs say that a plugin with a conflicting requirement may cause an error if the tree cannot be resolved[1]. That error is ERESOLVE: npm throws unable to resolve dependency tree with the code ERESOLVE[6], and prints a report of what it found[8][9]. That is why a project that installed fine with an old npm can fail with a new one.
Not every conflict is fatal. Conflicts deep in the tree are resolved with the nearest non-peer version and a warning, ERESOLVE overriding peer dependency[2][7]. Setting strict-peer-deps turns those warnings into failures too[2].
How to read the report
The report has the same parts every time[9]:
While resolving— the package npm was working on.Found— the version that is already in the tree, and who asked for it. Above,[email protected], requested by your ownpackage.json(“the root project”).Could not resolve dependency— the requirement that does not fit:@acme/[email protected]wantsreact17 or 18.Conflicting peer dependency(when present) — the peer version that clashes with what is already there.
So the example reads: your project asks for React 19, and the date picker only supports React 17 and 18. npm also writes the full report, without the depth limit, to a file ending in eresolve-report.txt[8][9].
The real fix: make the versions match
The flags in the message accept a resolution that npm itself calls incorrect and potentially broken[9]. The fix that makes the error go away for good is a set of versions that agree.
1. Upgrade the package that is behind
Usually the plugin has a newer release that supports your host version. Check what each release accepts with npm view, which takes a version and a field name[5]:
npm view @acme/date-picker versions
npm view @acme/date-picker@latest peerDependencies
If the latest release accepts react 19, install it and commit both files:
npm install @acme/date-picker@latest
git add package.json package-lock.json
2. Or use the host version the plugin supports
If no release of the plugin supports the new major yet, stay on the version it does support until one does. In the example, that is React 18:
npm install react@18 react-dom@18
3. Find who wants what
In a larger tree the conflicting package may not be in your package.json at all. npm explain (also npm why) prints the chain of dependencies that causes a package to be installed[4]:
npm explain react
Upgrade the package at the top of the chain that pulls in the old requirement.
4. Override a version you have tested
When you have checked that the plugin works with the newer host, and only its declared range is behind, overrides in the root package.json replaces a package’s version anywhere in the tree[1]. Overrides are read only from the root package.json, not from dependencies or workspaces[1].
You cannot override a package you also depend on directly unless both use exactly the same spec, or npm throws EOVERRIDE. The documented way around it is a $ reference to your own dependency’s spec[1]:
{
"dependencies": {
"react": "^19.0.0",
"@acme/date-picker": "^2.4.0"
},
"overrides": {
"react": "$react"
}
}
Overrides can also be limited to one parent package, or nested deeper[1]. Run npm install afterwards and commit the lockfile. An override is a promise that you tested the combination; remove it when the plugin catches up.
The workarounds: –legacy-peer-deps and –force
Both make the install pass without changing a single version. Use them knowing what they do.
| Flag | What it does | Risk |
|---|---|---|
--legacy-peer-deps |
Ignores peerDependencies completely when building the tree, as npm 3 to 6 did[2] |
Peer requirements are not enforced; npm does not recommend it[2] |
--force |
Removes many protections; one of them allows conflicting peer dependencies in the root project[2] | Also skips engines checks and more; npm strongly recommends against it unless you know exactly why[2] |
--strict-peer-deps |
The opposite: every peer conflict fails, even deep ones[2] | Stricter installs; when it is on, the message also suggests --no-strict-peer-deps[9] |
Of the two, --legacy-peer-deps changes less, because --force turns off a whole list of unrelated checks[2]. Either way, the app may break at runtime exactly where the peer requirement said it would.
Make it the same on every machine: .npmrc
A flag typed on your laptop is not used by CI or the server. npm reads a per-project config file, .npmrc next to package.json, written as key = value lines[3]. The config key is legacy-peer-deps[2]:
legacy-peer-deps=true
Commit it, so every npm install in the project, on any machine, runs with the same setting, and delete it once the versions match.
How to confirm the fix locally
Install the way a server does, from a clean tree and the committed lockfile:
rm -rf node_modules
npm install # must finish without ERESOLVE
git status # commit package.json, package-lock.json and .npmrc if they changed
rm -rf node_modules
npm ci
To check with the server’s Node and npm rather than yours, run the same in a container, for example docker run --rm -v "$PWD":/app -w /app node:22 npm ci.
On Livops
-
Where it shows. A failed install stops the deploy as
install_failed; the error itself is in the build log, and the previous version keeps running. See Install failed. -
A Tip line for ERESOLVE. When the log says
ERESOLVE, it ends with a Tip: line for this case: fixpackage.json, or set Settings → Install tonpm install --legacy-peer-deps. Fixing the versions is the better of the two, for the reasons above. -
Set the install yourself. The same command can live in
livops.jsonat the root of the repository or the project folder.installis applied on every deploy, and while the file names it, the file wins over the cabinet:{ "install": "npm install --legacy-peer-deps" }A committed
.npmrcwithlegacy-peer-deps=trueworks without changing the command, because npm reads it itself. -
The assistant explains. Next to the failed build, the assistant’s button reads the log and tells you what happened and how to fix it. See AI assistant.
If the install gets past dependency resolution but fails compiling a package, see gyp ERR! build error: node-gyp rebuild failed; for other failures that end in code 1, see npm error code 1.
Questions
What does ERESOLVE unable to resolve dependency tree mean?
npm could not build one tree of packages that satisfies every version range in it. Almost always it is a peer dependency: a plugin says it works with, for example, react 17 or 18, while your project asks for react 19. npm 7 and later install peer dependencies, so they have to fit.
Is --legacy-peer-deps safe?
It makes npm ignore peer dependencies completely, as npm 3 to 6 did. npm's own docs say it is not recommended, because packages may rely on the peer contract. It is acceptable as a stopgap when you have checked that the combination works, and better than --force, which removes many other protections too.
What is the difference between --force and --legacy-peer-deps?
--legacy-peer-deps only changes how peer dependencies are handled: they are ignored. --force removes a whole list of safety checks, one of which allows conflicting peer dependencies in the root project. npm's error message says either one accepts an incorrect and potentially broken resolution.
Why did npm install work before and fail now?
In npm 3 to 6 peer dependencies were not installed and a wrong version only printed a warning. Since npm 7 they are installed, so a conflict that used to be a warning now stops the install.
How do I make --legacy-peer-deps apply everywhere?
Put legacy-peer-deps=true in a .npmrc file in the project root and commit it. npm reads that per-project file on every machine, so your laptop, CI and the server install the same way. Remove it once the versions match.
Should I delete package-lock.json to fix ERESOLVE?
No. The conflict is between the version ranges packages declare, not in the lockfile, so a fresh lockfile usually hits the same conflict. Change the versions that disagree instead.
Sources
- npm Docs — package.json (peerDependencies, overrides) (docs.npmjs.com). Checked .
- npm Docs — config (legacy-peer-deps, strict-peer-deps, force) (docs.npmjs.com). Checked .
- npm Docs — .npmrc (docs.npmjs.com). Checked .
- npm Docs — npm explain (docs.npmjs.com). Checked .
- npm Docs — npm view (docs.npmjs.com). Checked .
- npm source — workspaces/arborist/lib/arborist/build-ideal-tree.js (github.com). Checked .
- npm source — workspaces/arborist/lib/place-dep.js (github.com). Checked .
- npm source — lib/utils/error-message.js (github.com). Checked .
- npm source — lib/utils/explain-eresolve.js (github.com). Checked .
- npm 10.5.2 source — lib/utils/display.js (raw.githubusercontent.com). Checked .
- npmlog source — lib/log.js (github.com). Checked .
- npm 10.6.0 source — lib/utils/display.js (raw.githubusercontent.com). Checked .
- npm source — workspaces/config/lib/definitions/definitions.js (heading) (github.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your Node appRelated
- gyp ERR! build error / gyp ERR! find Python: node-gyp rebuild failed during npm install, how to fix itgyp ERR! build error, gyp ERR! find Python or gyp ERR! stack Error: not found: make means npm install tried to compile a native addon such as bcrypt, sqlite3 or sharp, and the machine has no Python, make or C++ compiler. It usually happens because no prebuilt binary fits your Node version or platform (Alpine/musl included). Upgrade to a release with prebuilt binaries, switch to a pure-JavaScript package such as bcryptjs, or install the build tools.
- npm failed with return code 1 (npm ERR! code 1): how to fix the buildnpm failed with return code 1, or npm install exited with 1, is npm ERR! code 1 in newer npm: it only says that a script npm ran exited with code 1. The real error is printed above it: usually a compile or type error, a lockfile out of sync with package.json, or a dependency whose install script failed. Find the first error line above code 1, fix that, and the build passes.
- npm ci can only install packages when your package.json and package-lock.json are in sync: how to fix itnpm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync (npm error code EUSAGE) means the committed lockfile no longer matches package.json: a dependency was added or changed without re-running npm install, or the lockfile was not committed. Run npm install locally, commit package.json and package-lock.json together, and npm ci passes.
- Error: Cannot find module (MODULE_NOT_FOUND) in Node.js: how to fix itError: Cannot find module 'x' with code MODULE_NOT_FOUND, or ERR_MODULE_NOT_FOUND with import, means Node.js looked for a package or file and it was not there. On a server the usual causes are a package missing from package.json, a devDependency the install skipped, a path whose case differs from the file, a start command pointing at a file that was never built, or an ES module import without its .js extension.
- Node.js hosting in 2026: how to deploy an Express appA Node.js server in production needs one long-running process that listens on the port it is given, restarts when it crashes and exits cleanly on SIGTERM. On Livops you push a repository with package.json and it runs as a web app for 39 credits a month (39,000 so'm). Here is what Node needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.
- ERR_PNPM_OUTDATED_LOCKFILE: Cannot install with frozen-lockfile because pnpm-lock.yaml is not up to date: how to fix itERR_PNPM_OUTDATED_LOCKFILE means pnpm was told to install exactly what pnpm-lock.yaml says (frozen-lockfile, the default in CI when a lockfile is present), and the lockfile no longer matches a package.json: a dependency was added or changed without re-running pnpm install, or the updated lockfile was never committed. Run pnpm install locally, commit pnpm-lock.yaml, and the install passes.