EthioDeploy
DocsPricingDomainsBlogToolsChangelog

Blog/Fix deploy errors

npm ERESOLVE peer dependency error on deploy

BS
Brook SolomonPublished November 15, 2026
Share on XShare on LinkedIn
npm error code ERESOLVE

THE SHORT ANSWER

ERESOLVE means a package's peerDependencies range doesn't accept the version your project already uses, and npm 7 and later refuse to build that tree. It often passes locally because your package-lock.json was made with --legacy-peer-deps, your ~/.npmrc sets legacy-peer-deps=true, or your local npm is older, while the build server runs a clean npm ci without any of that. Fix it by upgrading the package to a version whose peer range fits, by forcing the version with overrides in package.json, or, as a last resort, by committing legacy-peer-deps=true in a project .npmrc so every install, local and on deploy, resolves the same way.

How do I read the ERESOLVE error?

A typical failure looks like this (package names are examples):

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.2.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^17.0.0 || ^18.0.0" from [email protected]
npm error node_modules/some-chart-lib
npm error   some-chart-lib@"^3.1.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.

Older npm versions print npm ERR! instead of npm error. Read it in three parts:

  • Found: is what your project already has: [email protected], required by your own package.json.
  • Could not resolve dependency: is the package that disagrees. some-chart-lib declares react as a peer dependency and only accepts 17 or 18.
  • Conflicting peer dependency:, when present, names the version npm would have needed to install to satisfy that peer.

npm also writes the full explanation to eresolve-report.txt in its cache folder. A variant, ERESOLVE could not resolve, is the same kind of conflict raised at a different step of building the tree.

Why does it fail on deploy but not on my machine?

npm's package.json docs: “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.” A conflicting peer that used to be a warning is now an error. If you never see it locally, something on your machine is different from the build server:

  • The lockfile was made with --legacy-peer-deps. Someone ran npm install --legacy-peer-deps once, it worked, and the lockfile was committed. The build server runs npm ci without the flag. npm's docs on npm ci: if the lockfile was created with flags like --legacy-peer-deps, “you must provide the same flags to npm ci or you are likely to encounter errors.”
  • Your user .npmrc sets it. A legacy-peer-deps=true line in ~/.npmrc applies to every project on your machine and to none on the server. Run npm config get legacy-peer-deps to check.
  • A different npm version. Compare npm -v locally with the version in the build log. npm 6 only warned about peer conflicts; 7 and later fail.
  • No lockfile, or one out of date. Without a committed package-lock.json, the server resolves every range again and can pick a newer release than the one you have, with a different peer range.

Fix 1: make the versions agree

The real fix is a set of versions that fit. Check whether a newer release of the package widened its peer range:

npm view some-chart-lib peerDependencies
npm view some-chart-lib@latest peerDependencies

If the latest version accepts your React, upgrade to it. If no version does yet, either wait, switch packages, or move your own dependency to a version inside the range (here, React 18). Then run a plain npm install with no flags, commit the new package-lock.json, and the deploy resolves the same tree.

npm explain react (or npm ls react) shows every package that depends on a given one, which helps when the conflict sits several levels down.

Fix 2: force one version with overrides

When you know the package works with your version and its peer range is just out of date, tell npm to use your version anyway. overrides in the root package.json replaces a version anywhere in the tree, and can be scoped to one parent package:

{
  "dependencies": {
    "react": "^19.2.0",
    "some-chart-lib": "^3.1.0"
  },
  "overrides": {
    "some-chart-lib": {
      "react": "$react"
    }
  }
}

$react means “the spec of my direct react dependency”. npm's docs recommend this reference form because you can't override a package you depend on directly with a different spec: that throws EOVERRIDE. Overrides only work in the root package.json, not in dependencies or workspaces.

Unlike --legacy-peer-deps, this is narrow: one package, one peer, written down in package.json where the next person can see it. Every other peer check still runs. Test the feature that uses the package, since its authors haven't promised it works.

Fix 3: legacy-peer-deps in .npmrc

legacy-peer-deps makes npm ignore peerDependencies completely, “as in npm versions 3 through 6”. npm's docs add that its use “is not recommended, as it will not enforce the peerDependencies contract that meta-dependencies may rely on.” It turns off every peer check, not only the one that failed.

If you use it anyway, don't pass it as a flag on your machine only. Commit it, so local installs, npm ci and the build server all build the same tree. npm's own suggestion:

npm config set legacy-peer-deps=true --location=project
git add .npmrc package-lock.json

That writes legacy-peer-deps=true to an .npmrc next to package.json. Delete node_modules and run npm install once so the lockfile matches the setting. If you can't add files to the repo, an environment variable does the same thing: npm reads any variable starting with npm_config_ as config, so npm_config_legacy_peer_deps=true works during the build.

Avoid --force for this. It does let conflicting peers into the root project, but it also removes a list of unrelated protections, such as engines checks, and the docs say that without a clear idea of what you want, “it is strongly recommended that you do not use this option!”

npm ci vs npm install on a build server

Build servers usually run npm ci when a lockfile exists. npm's docs list how it differs from npm install:

  • The project must have a package-lock.json or npm-shrinkwrap.json.
  • If the lockfile doesn't match package.json, it exits with an error instead of updating it.
  • It removes any existing node_modules first.
  • It never writes to package.json or the lockfile.

npm ci still works out the dependency tree before installing, so a peer conflict fails it with the same ERESOLVE. An out-of-sync lockfile gives a different error, which starts “npm ci can only install packages when your package.json and package-lock.json are in sync”. The fix for that one is running npm install locally and committing the lockfile.

Don't switch the build to npm install to dodge ERESOLVE. It hits the same check, and npm ci is what guarantees the server installs what you tested.

What happens on EthioDeploy?

The build picks the install command from your lockfile: npm ci when package-lock.json is committed, npm install when it isn't (pnpm, Yarn and Bun lockfiles get their own frozen installs). Node 22 is the default, which ships with npm 10, unless engines.node in package.json asks for another version.

The ways to apply the fixes above:

  • Commit the updated package.json and package-lock.json (fixes 1 and 2) and push.
  • Commit an .npmrc with legacy-peer-deps=true next to package.json. The whole repo is in the build, so npm reads it.
  • Or add npm_config_legacy_peer_deps=true as an environment variable. Env vars are available during the build.
  • Or set the Install Command in Settings → Build, for example to npm ci --legacy-peer-deps.

If the project builds from your Dockerfile, the Install Command is ignored and your Dockerfile's RUN npm ci line is what runs, so put the .npmrc in the build context before that line. The deploy's build log shows the full ERESOLVE text. For a build that gets further and then dies, see JavaScript heap out of memory during next build.

Questions

A package lists a peer dependency range that doesn't include the version your project uses, and npm 7 and later won't install a tree that breaks a peer range. The Found and Could not resolve dependency lines name the two sides.

It works, but npm's docs call it not recommended: it ignores every peerDependencies range, not just the one that failed. Prefer upgrading the package or a scoped override, and if you do use it, commit it in .npmrc so every install matches.

--legacy-peer-deps ignores peer dependencies while building the tree. --force allows conflicting peers in the root project but also removes other protections, like engines checks, and npm's docs strongly recommend against it unless you know exactly why you need it.

Usually the lockfile was created with --legacy-peer-deps or another tree-shaping flag, and npm ci runs without it. npm's docs say npm ci needs the same flags; committing them in .npmrc does that. An out-of-sync lockfile is a separate error that npm install fixes.

No. It's an npm config setting, so it goes in a project .npmrc file or an npm_config_legacy_peer_deps environment variable. package.json has overrides, which is the narrower alternative.

Sources

Checked on November 15, 2026:

  • npm: npm ci
  • npm: package.json (peerDependencies, overrides)
  • npm: config (legacy-peer-deps, force)
  • npm: npmrc
  • npm source: explain-eresolve.js
  • Node.js release index (bundled npm versions)

Push a repo. Get a URL.

  • Deploy a Node.js app
  • Deploy a Next.js app
  • Environment variables
  • Troubleshooting deploys
Start free

Join the EthioDeploy Telegram

Release notes as they ship, plus deploy help from the team and other developers.

Join on Telegram
BS
WRITTEN BYBrook SolomonFounder, EthioDeploy

Brook Solomon founded EthioDeploy and builds its deploy pipeline, build servers and AI coding agent. The posts here come from errors seen in real deploys on the platform.

All posts by Brook →
On this page
  • How do I read the ERESOLVE error?
  • Why does it fail on deploy but not on my machine?
  • Fix 1: make the versions agree
  • Fix 2: force one version with overrides
  • Fix 3: legacy-peer-deps in .npmrc
  • npm ci vs npm install on a build server
  • What happens on EthioDeploy?
  • Questions
  • Sources
0% read

Keep reading

  • 53300

    Fix deploy errorsNov 17, 2026

    Postgres "too many connections" after deploy: how to fix it

    Postgres refuses new connections with "FATAL: sorry, too many clients already" (SQLSTATE 53300, too_many_connections) once every slot under max_connections is taken, and max_connections defaults to 100. After a deploy the usual cause is arithmetic: each process of your app opens its own pool (10 for node-postgres and Prisma 7, 15 for SQLAlchemy), you run several processes, and for a short time the old and the new copy of the app are both connected. Count connections in pg_stat_activity, make copies × processes × pool max fit under the limit with room to spare, release clients you check out, set idle_in_transaction_session_timeout, and put PgBouncer in front when the numbers can't fit.

  • NEXT_PUBLIC_*

    Fix deploy errorsNov 17, 2026

    NEXT_PUBLIC_ env variables undefined in production: causes and fixes

    A NEXT_PUBLIC_ variable is undefined in production when it wasn't set while next build ran. Next.js replaces every process.env.NEXT_PUBLIC_ reference with a fixed value during the build, so a variable added to the server afterwards changes nothing until you build again. The other usual causes are reading it dynamically (process.env[name] or a copy of process.env), a name without the NEXT_PUBLIC_ prefix in a Client Component, and one Docker image promoted across environments. For values that must change without a rebuild, read them on the server at request time and pass them down.

  • Invalid HTTP_HOST header

    Fix deploy errorsNov 15, 2026

    Django DisallowedHost and CSRF errors behind a proxy

    DisallowedHost means the request's Host header isn't in ALLOWED_HOSTS, so Django answers 400; add your production domain to the list. The CSRF 403 "Origin checking failed - https://... does not match any trusted origins" usually means Django thinks the request came over plain HTTP: the proxy ended HTTPS and forwarded it as HTTP, so Django expects an http:// origin and the browser sent https://. Set SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") when your proxy sets that header. Since Django 4.0, entries in CSRF_TRUSTED_ORIGINS must include the scheme, such as https://example.com.

EthioDeploy

Agentic first development and deployment, started in Ethiopia, built for developers everywhere.

Telegram community
Product
PricingAI coding agentAgent mode docsDomainsCLIFree backend hostingHosting in EthiopiaChangelog
Deploy guides
Next.jsNode.jsPythonSvelteKitTanStack StartAstroNuxtReact RouterHonoStrapiDjangoFastAPIFlaskStreamlitExpressNestJSLaravelRailsGoTelegram botDiscord botLovableBoltReplitv0Google AI StudioBase44Firebase StudioClaude Code & Cursor
Compare
vs Herokuvs Vercelvs Rendervs Railwayvs Fly.iovs Netlifyvs KoyebHeroku alternativesVercel alternativesNetlify alternativesRender alternativesRailway alternativesFly.io alternativesReplit alternativesPythonAnywhere alternativesDigitalOcean App Platform alternativesGlitch alternatives
Resources
DocsBlogFree toolsAboutSupportContactllms.txt
© 2026 EthioDeployPay by card in USD or bank transfer in ETBTermsPrivacy