Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

npm EBADENGINE: Unsupported engine and the Node version behind it

EBADENGINE compares package engines with your Node build. Align .nvmrc, engines, and CI images, and understand when engine-strict makes it fatal.

~5 min readNode.js
#npm#nodejs#engines#ci
Bold white headline reading EBADENGINE with a Node runtime crate refusing an amber package card that demands a newer version.

Introduction & Quick Summary

npm install in CI finishes its progress bar and then prints:

code
npm WARN EBADENGINE Unsupported engine { package: 'vite@6.3.5', required: { node: '^18.0.0 || ^20.0.0 || >=22.0.0' }, current: { node: 'v18.17.1', npm: '9.6.7' } }

or, when strict mode is on:

code
npm ERR! code EBADENGINE npm error notsup Required: {"node":">=20.19.0"} npm error notsup Actual: {"npm":"10.8.2","node":"v18.20.4"}

Quick answer: the installed Node.js does not satisfy a package.json engines range. Normally npm only warns; it fails hard when engine-strict=true is set in .npmrc, or when you pass --engine-strict. Fix the runtime rather than the flag:

bash
node -v # what you have cat .nvmrc 2>/dev/null # what the project wants npm config get engine-strict # true or false nvm install --lts && nvm use # or volta/asdf to match engines rm -rf node_modules package-lock.json && npm ci

The warning is easy to dismiss and expensive to ignore: a package whose code uses node:sqlite, Promise.withResolvers, or native modules built against a newer ABI will fail at import time or at runtime, long after the install looked fine.

Core Mechanics, Signatures & Reproducible Setup

engines is a field in package.json describing the runtimes a package supports:

{ "name": "my-app", "engines": { "node": ">=20.19.0 <25", "npm": ">=10" }, "packageManager": "pnpm@10.4.1" }

npm evaluates this field for the root project and for every dependency it reads, then compares the result against process.versions.node of the npm process. Three rules decide the outcome:

  1. engine-strict=false (the default) turns a mismatch into WARN EBADENGINE and continues.
  2. engine-strict=true turns it into ERR! code EBADENGINE and aborts before writing to node_modules.
  3. The check compares ranges, not versions, so a pre-release tag such as v22.0.0-rc.1 fails a >=22 range unless the range names the pre-release.

Reproduce it locally without touching a real project:

bash
mkdir ebadengine && cd ebadengine cat > package.json <<'EOF' { "name": "t", "version": "1.0.0", "engines": { "node": ">=20" }, "dependencies": { "ms": "^2.1.3" } } EOF printf 'engine-strict=true\n' > .npmrc npm install # ERR! code EBADENGINE on Node 18 sed -i 's/>=20/>=18/' package.json # or upgrade Node npm install # succeeds

The message always names both sides — required from the manifest, current from the runtime — so there is no ambiguity about which package and which engine.

Key Comparison Table

Strictness differs by package manager, which matters when only one of them fails:

Package managerDefault on mismatchFlag to enforceMessage
npm 9/10/11warningengine-strict=true in .npmrcWARN EBADENGINE / ERR! code EBADENGINE
pnpm 9/10error for the root projectengine-strict=false to relaxERR_PNPM_UNSUPPORTED_ENGINE
Yarn 1warning--ignore-engines to relaxThe engine "node" is incompatible
Yarn 4 (berry)errorenableEngineChecks settingYN0002-style engine report
Bunwarning--frozen-lockfile unaffectedwarn: ... requires node

Which failure you are looking at:

MessageRaised byMeaning
WARN EBADENGINEnpm, non-strictinstall continued, package may misbehave
code EBADENGINEnpm, strictinstall aborted
ERR_PNPM_UNSUPPORTED_ENGINEpnpmroot project engine mismatch
notsup Required/Actualnpmthe two ranges being compared
Cannot find module 'node:sqlite'Node runtimethe engine warning was real

Fixing it, and what each option costs:

OptionEffortRisk
upgrade Node in CI and locallyone line in the workflownone, and it matches the package's support window
add .nvmrc plus engines to the reposmallneeds a version manager in every environment
pin with packageManager and CorepacksmallCorepack must be enabled on the runner
engine-strict=falseone linedefers a runtime failure to the worst moment
npm install --forceone flagskips peer and engine checks, hides real breakage

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Find the package that actually wants the newer Node

bash
npm ls --depth=0 npm explain vite # which path pulled the package in node -p "process.versions.node" npx -y npm@10 ls --json > deps.json

npm explain prints the dependency chain, which is what you need when a fresh transitive dependency raises the engine floor two days before a release.

2. Align the repository so every machine agrees

jsonc
// package.json { "engines": { "node": ">=20.19.0 <25" } }
bash
# .nvmrc 20.19.0
# .github/workflows/ci.yml - uses: actions/setup-node@v4 with: node-version-file: .nvmrc cache: npm - run: npm ci

node-version-file removes the second source of truth; a workflow that hardcodes node-version: 18 will drift the moment .nvmrc changes.

3. npm itself can be the mismatch

The notsup block includes an npm entry, so a project with "npm": ">=10" fails under npm 9 even with Node 22. The fix is npm i -g npm@10, or Corepack, which also pins the package manager per repository:

bash
corepack enable corepack use pnpm@10.4.1 # writes packageManager and installs it

4. Docker and devcontainer base images

FROM node:18-alpine is the most common source of EBADENGINE in a pipeline that passes locally:

dockerfile
# dockerfile FROM node:22.14-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build

Pin the major version the engines field allows, and let Renovate or Dependabot bump both files in one pull request so they cannot diverge.

5. When the dependency, not you, is above your runtime

An old application on Node 18 pulling a package that requires >=20 has three honest options: upgrade the application, pin the package to its last compatible major (overrides in npm, resolutions in Yarn), or accept the warning and test the affected code path.

jsonc
{ "overrides": { "vite": "5.4.19" } }

overrides changes one subtree and keeps the rest current, which is usually smaller than a runtime upgrade done under deadline — but it must be paired with a test that exercises the feature you are pinning.

6. Reading the installed tree instead of the lockfile

bash
npm ci --engine-strict # fail early, in CI npm ls --all 2>/dev/null | grep -i "invalid\|UNMET" | head

Running strict in CI and loose locally is a useful asymmetry: developers get a warning they can finish their task with, and the merge gate is the place that refuses.

Common Compilation/Runtime Mistakes & Version Gotchas

Putting engines only in the root package.json and expecting enforcement. It describes your project; it does not restrict dependencies. Enforcement is engine-strict, and it applies to every package npm reads.

Using --force to make the message go away. npm install --force skips engine and peer validation together, so a genuine React version conflict and a Node version conflict disappear from the log at the same time. The build fails later with a less obvious message.

Assuming engine-strict is inherited from a parent folder. npm reads .npmrc from the project, then the user config; a CI runner with engine-strict=true in ~/.npmrc will fail installs that pass on a laptop, and the error looks unrelated to the change that triggered it.

Range syntax surprised. "node": "18" means exactly 18.x and excludes 20 and 22. ">=18" allows 18 through 25 and is the usual intent. "^18 || ^20 || >=22" is the shape most libraries now ship, and it is why a Node 18.17 install can fail a package that accepts Node 18 generally.

Version boundaries worth knowing. npm 7 changed peer-dependency resolution and made more engine checks visible. Node 18 reached end of life in April 2025, and the packages that dropped it did so with a major bump, so a lockfile regeneration — not a code change — is often what triggers EBADENGINE. pnpm 10 enforces root engines by default and adds onlyBuiltDependencies prompts, which makes it stricter than npm on the same project.

Confirming the runtime is what you think. Print process.versions.node from inside the failing step; a PATH entry pointing at an old Node from a version manager is a frequent cause. The environment variable reference helps untangle PATH, NODE_OPTIONS, and proxy variables in one place, and the JSON formatter is handy for diffing two package.json files when a monorepo has several.

Reference material: package.json engines and npm config engine-strict.

Official references

primary documentation

The Node.js documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Node.js work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Node.js guides

More in Node.js

All Node.js guides

The guides filed next to this one in Node.js, in library order.