About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When npm install ends with npm ERR! code ERESOLVE or npm error code ERESOLVE and the message unable to resolve dependency tree, npm could not build a tree in which every package gets a peer dependency inside the range it asked for. Read which package asks for which version, and change a version or add an override. The flags that skip the check, --legacy-peer-deps and --force, come last.
What the error means
A peer dependency is how a plugin says which host package and version it works with. npm's package.json page says: "In npm versions 3 through 6, peerDependencies were not automatically installed, and would raise a warning if an invalid version of the peer dependency was found in the tree. As of npm v7, peerDependencies are installed by default." Since npm 7 a clash is therefore an error, not a warning.
The error is raised in npm's dependency builder. In the CLI source at v10.9.2, the builder throws new Error('unable to resolve dependency tree') with code ERESOLVE when it fails a peer conflict. The summary and report come from lib/utils/explain-eresolve.js. In that file the report has these parts, in order: "While resolving:", "Found:", "Could not resolve dependency:" and, where a peer is involved, "Conflicting peer dependency:". It ends with the advice "Fix the upstream dependency conflict", then names the flags --force or --legacy-peer-deps (and --no-strict-peer-deps when strict peer dependencies are on) "to accept an incorrect (and potentially broken) dependency resolution." The source comment says the full report is always written to the cache folder, and lib/utils/error-message.js names the file eresolve-report.txt. The same file lists code among the error fields. Our own reading: the code ERESOLVE line comes from that list.
The prefix differs by release. The v8.19.4 source defines the error level with the heading ERR!, and the v10.9.2 display code builds the prefix from the heading npm and the level, which gives npm error.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| A plugin needs an older or newer host than the root has | Found: shows the root's version, Could not resolve dependency: shows the plugin's range |
npm explain on the host package |
| Two plugins ask for different ranges of one peer | Both plugins' ranges appear in the report, and a Conflicting peer dependency: line names the peer package and version npm tried to place |
npm ls on the peer |
| The project moved from npm 6 or earlier | Installs worked before; the error starts on npm 7 or later | npm --version |
strict-peer-deps is on |
Conflicts npm could guess a resolution for still fail | npm config get strict-peer-deps |
| An old lockfile pins a version | Error follows a dependency bump in package.json | Compare package-lock.json with package.json |
Prove the cause before changing anything
All of these only read.
1. Read the report. Note the three package names and versions: the one Found:, the package in Could not resolve dependency: and the range it asks for, and the Conflicting peer dependency: line if present. The full report is in the cache folder. npm's config page gives the default cache location as %LocalAppData%\npm-cache on Windows and ~/.npm on POSIX; print the active one with:
npm config get cache
2. Explain why the package is in the tree. npm's page says npm explain "will print the chain of dependencies causing a given package to be installed in the current project".
npm explain example-host
3. List the versions installed. The npm ls page says it prints "extraneous, missing, and invalid packages".
npm ls example-host
4. Preview the install. npm's dry-run setting, per the config page, means npm should "only report what it would have done". Our own reading is that a remaining conflict still ends in the same error.
npm install --dry-run
5. Check strictness and version.
npm --version
npm config get strict-peer-deps
Fix
Work down the list and stop at the first fix that gives a clean install. Each one changes package.json and package-lock.json, so save both first.
Install a version the plugin accepts
First save the current state:
cp -p package.json package.json.2026-12-03
cp -p package-lock.json package-lock.json.2026-12-03
Risk: the next command changes a dependency version in package.json and package-lock.json and installs it into node_modules. Code that relies on the older version can break.
Choose the host version, or the plugin version, that makes the ranges overlap. npm's install page says npm install <name>@<version> installs the specified version and fails if it has not been published.
npm install example-plugin@4.3.0
To undo it, only if you need to: the copies below overwrite the current package.json and package-lock.json, so any edit made to them since the save is lost. They restore only those two files; node_modules is not saved and stays as the install left it, so run npm ls afterwards and read any invalid or missing lines. Copy the saved files back.
cp -p package.json.2026-12-03 package.json
cp -p package-lock.json.2026-12-03 package-lock.json
Add an override in package.json
First save the current state:
cp -p package.json package.json.2026-12-03
cp -p package-lock.json package-lock.json.2026-12-03
Risk: the next edit, and the npm install after it, change package.json, package-lock.json and node_modules, and make npm install a version of a package that the package asking for it did not list. npm's page describes overrides as a way to replace a package in the tree "with another version, or another package entirely", and the plugin has not been tested against it by its author.
Edit the root package.json. The page says overrides "are only considered in the root package.json file". To make example-host resolve to 3.1.0 everywhere:
{
"overrides": {
"example-host": "3.1.0"
}
}
The page warns that an override for a package you depend on directly must share the exact same spec, or npm throws EOVERRIDE; a $ reference to the direct dependency avoids that. Then install with the new override in place:
npm install
Check the result with npm ls example-host.
To undo it, only if you need to: the copies below overwrite the current package.json and package-lock.json, so any edit made to them since the save is lost. They restore only those two files; node_modules is not saved and stays as the install left it. Copy the saved files back, then check with npm ls example-host.
cp -p package.json.2026-12-03 package.json
cp -p package-lock.json.2026-12-03 package-lock.json
Accept the conflict with a flag (last resort)
npm's config page says legacy-peer-deps "Causes npm to completely ignore peerDependencies when building a package tree" and adds "Use of legacy-peer-deps is not recommended". Its force entry ends: "If you don't have a clear idea of what you want to do, it is strongly recommended that you do not use this option!" Run only the one that applies.
First save the current state:
cp -p package.json package.json.2026-12-03
cp -p package-lock.json package-lock.json.2026-12-03
Risk: the next command builds the tree without checking peer dependencies, so a plugin may be installed against a host version it was not written for, and the fault can appear later at run time instead of now.
npm install --legacy-peer-deps
Risk: the next command lets conflicting peer dependencies be installed in the root project, and removes other protections the config page lists.
npm install --force
To undo either one, only if you need to: the copies below overwrite the current package.json and package-lock.json, so any edit made to them since the save is lost. They restore only those two files; node_modules is not saved and stays as the install left it. Copy the saved files back, then check with npm ls.
cp -p package.json.2026-12-03 package.json
cp -p package-lock.json.2026-12-03 package-lock.json
Example (illustrative): On app01, npm install in example-org/example-repo fails with ERESOLVE. Found: names example-host at version 3.1.0, and Could not resolve dependency: names example-plugin at version 4.2.0, which asks for example-host in the range ^2.0.0. npm explain example-plugin shows the plugin is a direct dependency of the root. The maintainers' version example-plugin@4.3.0 asks for example-host@^3.0.0, so the team saves both files, installs 4.3.0, and npm ls example-host shows no invalid line.
Confirm the fix
npm installends without ERESOLVE.npm lsprints noinvalidormissinglines for the packages in the report.- The project's own tests and build pass, because a flag or override can hide a real incompatibility.
package-lock.jsonis committed together withpackage.json.
What to watch afterwards
- Keep plugin and host versions moving together; npm's page says plugin authors should keep peer ranges broad.
- Remove an override once the plugin's own range allows the host version you use.
- Do not put
--legacy-peer-depsinto a build script unnoticed: it applies to every install that script runs.
Read next
Related articles you may want next.
- Troubleshootingpip "error: externally-managed-environment": use a virtual environment or pipx instead of the system Pythonpip says error: externally-managed-environment? The system Python is marked by PEP 668. Use a virtual environment or pipx; the override flag risks the OS.Read article
- TroubleshootingNuGet NU1101 "Unable to find package": check the id, the configured sources and package source mappingNuGet NU1101 Unable to find package, no packages exist with this id in source(s)? Check the id, the nuget.config the build reads and source mapping.Read article
- TroubleshootingNode.js "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory": find what fills the heap before you raise the limitNode.js FATAL ERROR: Reached heap limit, JavaScript heap out of memory. Read the heap limit, capture snapshots, then raise --max-old-space-size safely.Read article
Risks and limits
- These commands have not been run or lab-tested.
- Message prefixes and wording are a reading of the v10.9.2 and v8.19.4 sources and may differ in other releases.
--legacy-peer-depsand--forceproduce a tree npm itself calls potentially broken.- Restoring the saved files does not restore
node_modules.
Sources
- npm-install — npm Docs, version 10 documentation, page dated 11 September 2024, accessed 3 December 2026
- config — npm Docs, version 10 documentation, page dated 19 January 2024, accessed 3 December 2026
- package.json — npm Docs, version 10 documentation, page dated 23 April 2025, accessed 3 December 2026
- npm-explain — npm Docs, version 10 documentation, page dated 5 October 2022, accessed 3 December 2026
- npm-ls — npm Docs, version 10 documentation, page dated 5 October 2022, accessed 3 December 2026
- npm-config — npm Docs, version 10 documentation, page dated 19 January 2024, accessed 3 December 2026
- explain-eresolve.js — npm CLI source repository, tag v10.9.2, no date shown, accessed 3 December 2026
- error-message.js — npm CLI source repository, tag v10.9.2, no date shown, accessed 3 December 2026
- build-ideal-tree.js — npm CLI source repository, tag v10.9.2, no date shown, accessed 3 December 2026
- display.js — npm CLI source repository, tag v10.9.2, no date shown, accessed 3 December 2026
- npm.js — npm CLI source repository, tag v10.9.2, no date shown, accessed 3 December 2026
- log.js — npm CLI source repository, tag v8.19.4, no date shown, accessed 3 December 2026
This article was originally published on .