Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

npm install fails with ERESOLVE during my Vercel deployment

Errornpm ERR! code ERESOLVE

Short answer

ERESOLVE means two packages ask for incompatible peer dependency versions and npm refuses to guess. On Vercel, set the project's Install Command to npm install --legacy-peer-deps, or fix the versions. Also check .npmrc: strict-peer-deps=true turns a warning into this failure.

  • Applies to npm 10, Node.js 22, Vercel
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Reproduce the install in a clean checkout. The error block names the package that wants one version and the package that has another.

    rm -rf node_modules
    npm install
  2. 2Match what you see, then jump to its fix

    1. 1The error block lists a Found version and a peer requirement that does not include itTwo packages need incompatible peer dependenciesFix
    2. 2The same project installs with warnings on one machine and fails on anotherstrict-peer-deps is on in .npmrcFix
    3. 3You added a flag locally, and the Vercel log still shows a plain npm installThe project's Install Command override is not what you thinkFix

What does the error look like?

  • npm ERR! code ERESOLVE
  • npm ERR! ERESOLVE unable to resolve dependency tree

Cause 1 of 3

Two packages need incompatible peer dependencies

1Check

Read the Found and peer lines in the error. The package on the peer line is the one whose supported range does not include the version you installed.

npm ls react

2Fix

Upgrade or replace the package whose peer range is too old. If you cannot, tell Vercel to install the way npm 6 did, with peer dependencies ignored. Set installCommand in vercel.json.

{
  "installCommand": "npm install --legacy-peer-deps"
}

3Verify

Redeploy. The Install step in the build log should finish without ERESOLVE.

vercel deploy

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 3

strict-peer-deps is on in .npmrc

1Check

With strict-peer-deps set to true, npm fails on any conflicting peer dependency instead of picking the nearest version and warning.

cat .npmrc
npm config get strict-peer-deps

2Fix

Remove the strict-peer-deps line from the project's .npmrc, or set it to false.

# .npmrc
strict-peer-deps=false

3Verify

Run a clean install again.

rm -rf node_modules
npm install

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 3

The project's Install Command override is not what you think

1Check

Vercel can override the install command from the dashboard, or per deployment with installCommand in vercel.json. A flag typed only in your terminal never reaches the build.

cat vercel.json

2Fix

Put the command you want in vercel.json, or in Settings, Build and Deployment, Install Command.

{
  "installCommand": "npm install --legacy-peer-deps"
}

3Verify

Open the new deployment's build log and read the install line.

# Dashboard: open the new deployment and read the install line in its build logs

Confirmed by vercel.com

Did this fix it?

How do I stop it coming back?

  • Commit package-lock.json so Vercel installs the tree you resolved locally.
  • Prefer upgrading the package whose peer range is out of date over ignoring peers.
  • Keep the Node.js and npm versions on your machine close to the ones in Vercel's project settings.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

tsconfig rejects allowImportingTsExtensions

An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.