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

Two packages in your project want different versions of a shared package, usually React, ESLint or TypeScript, and since npm 7 that mismatch stops the install instead of printing a warning.

How to read the error

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! Found: [email protected]
npm ERR!   node_modules/react
npm ERR!     react@"^19.0.0" from the root project
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0 || ^17.0.0 || ^18.0.0" from [email protected]

Read it as a sentence: you have react 19 (Found), but some-date-picker 4.2.1 says it only works with react 16 to 18 (peer … from). A peer dependency is a package a library expects you to provide, so it can share one copy with your app instead of bundling its own.

The real fixes, best first

  1. Upgrade the package that’s behind. npm view some-date-picker peerDependencies shows each version’s ranges; often a newer major already supports your React. npm outdated lists what has updates.
  2. Match versions instead. If the library has no compatible release yet, stay on the version it supports (for example npm install react@18 react-dom@18) until it catches up.
  3. Override, knowingly. If you have tested that it really works, tell npm in package.json:
    "overrides": {
      "some-date-picker": { "react": "$react" }
    }
    This is recorded in the project, so teammates and CI get the same result. Validate the file with the JSON formatter if npm complains about it.
  4. Swap the package if it looks abandoned (no release for years, open issues about your version).

What the flags really do

FlagEffectRisk
--legacy-peer-depsIgnores peer dependencies completely, like npm 4–6 didSilent runtime bugs if the versions really are incompatible; also skips peers you need
--forceInstalls anyway, picking versions even when they conflictCan create a tangled lockfile; harder to undo
overridesForces one specific version in one specific placeLowest, because it’s explicit and reviewed

If you do use --legacy-peer-deps, put legacy-peer-deps=true in the project’s .npmrc so CI behaves the same, and leave a note saying why.

“It worked yesterday”

Getting npm ERR! code ENOENT instead? See npm ENOENT fixed. Build dying with error:0308010C:digital envelope routines::unsupported after a Node bump? See Node OpenSSL envelope error.

Related

npm ERR! code ELIFECYCLE

Questions

Is it safe to use npm install --legacy-peer-deps?

Often it works, but it is a workaround: npm stops checking peer dependencies, so a real incompatibility will show up as a runtime bug instead of an install error. Prefer upgrading or an explicit override, and record the choice in .npmrc if you keep it.

What is the difference between --force and --legacy-peer-deps?

--legacy-peer-deps ignores peer dependencies entirely. --force still tries to install them but accepts conflicting versions. Both hide the problem; overrides in package.json is the explicit alternative.

Why did ERESOLVE start after upgrading npm?

Since npm 7, peer dependencies are installed and enforced automatically. Older npm only printed a warning, so conflicts that were always there now stop the install.

How do I find which package causes ERESOLVE?

Look at the line ending in 'from package@version' under 'Could not resolve dependency'. That package's peerDependencies range doesn't include the version shown under 'Found'. npm explain <package> shows who depends on what.

Published .

Try it

Related guides

Newest guides