Home·Error messages

npm · npm

The message

npm ERR! ERESOLVE unable to resolve dependency tree

What it means

From npm 7 onward peerDependencies ranges are enforced, and this says npm could not find a set of versions that satisfies all of them at once. It is common when the package you are installing has a peer range that excludes the react or typescript version you already have, especially right after a major upgrade. Read the Found: and Could not resolve: lines to see who demands what, then move one of the two to a compatible version — that is the real fix. npm install --legacy-peer-deps installs by ignoring peer ranges entirely, which unblocks you but leaves a tree the packages never agreed on, so the runtime errors from mismatched versions are yours to debug.

The fix

npm install --legacy-peer-deps
Printed by
npm
npm
20

With npm the cause sits in the first code XXXX line rather than the last six npm ERR! lines, and when the failure comes from the dependency tree or a native build instead of your own code, deleting node_modules and installing again clears about half of them.

Reading an error message

  • Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
  • If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
  • Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
  • The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
  • Before pasting a fix, check what it throws away. Some of these cannot be undone.

Common questions

Q. What does “npm ERR! ERESOLVE unable to resolve dependency tree” mean?

From npm 7 onward peerDependencies ranges are enforced, and this says npm could not find a set of versions that satisfies all of them at once. It is common when the package you are installing has a peer range that excludes the react or typescript version you already have, especially right after a major upgrade. Read the Found: and Could not resolve: lines to see who demands what, then move one of the two to a compatible version — that is the real fix. npm install --legacy-peer-deps installs by ignoring peer ranges entirely, which unblocks you but leaves a tree the packages never agreed on, so the runtime errors from mismatched versions are yours to debug.

Q. How do I fix it?

npm install --legacy-peer-deps — before running it, check the explanation above for what this command discards.

Q. Which tool prints this?

npm. It sits under npm, and the message runs to 8 words.

Errors nearby