A fresh clone of a pnpm-pinned repo will refuse npx, npm view and npm config get on npm 12, all under the same error code, and the fix depends on a line of the error that most answers skip. By the end of this you can reproduce it in four lines, read the error to tell whether any npm upgrade can fix it, and choose a fix that does not quietly disarm the pin for everyone else on the repo.
npm error code EBADDEVENGINES
npm error EBADDEVENGINES The developer of this package has specified the following through devEngines
npm error EBADDEVENGINES Invalid devEngines.packageManager
npm error EBADDEVENGINES Invalid name "pnpm" does not match "npm" for "packageManager"
npm error EBADDEVENGINES {
npm error EBADDEVENGINES current: { name: 'npm', version: '12.2.2' },
npm error EBADDEVENGINES required: { name: 'pnpm' }
npm error EBADDEVENGINES }
Short version: npm checks devEngines before every non-global command, because the gate in lib/npm.js tests commandInstance.checkDevEngines, an always-truthy method, instead of the static opt-in flag each command sets. Invalid name "pnpm" is unsatisfiable at any npm version; Invalid semver version is not. Adding { "name": "npm" } as a second array entry on devEngines.packageManager makes npx work again without touching --force.
What I read while working this out: the live bug report npm/cli#10301 (opened 15 November 2026, still open, labelled Bug / Priority 3), the one-line fix in npm/cli#10302, reggi's original feature PR npm/cli#7766, the checker itself in npm-install-checks lib/dev-engines.js, and the npm 12 package.json docs. The docs say the check "will run before install, ci, and run commands" and PR #7766 describes "a check for specific npm commands install, and run". Neither matches the shipped behaviour, which is why an assistant answering from documentation will tell you npx is unaffected. It is affected on every npm from 10.9.0 to 12.2.3. A different npm 12 gate throws on flags instead of engines; if your failure names a flag rather than a package manager, see EUNKNOWNCONFIG.
Prerequisites
- npm 12.2.3 (
npm -v). Source quoted below is thelatestbranch at 12.2.3. The same gate exists unchanged in 11.20.0 and 10.9.x, confirmed on all three by the reporter in #10301. The error block above is theirs, on 12.2.2; every command I run below is on 12.2.3. - Node 22.22.2+, 24.15.0+, or 26.x, matching npm 12's own
enginesfield of^22.22.2 || ^24.15.0 || >=26.0.0. - An empty scratch directory. Everything runs offline except the one
npxcall. - No pnpm, Yarn or Corepack installed. That is part of the point: the error comes from a
package.jsonfield with no other package manager present. If your failure iscorepack: not foundfrom the neighbouringpackageManagerfield instead, Node 26 dropped that binary and the fix is unrelated.
Step-by-step
1. Reproduce it in four lines
mkdir /tmp/devengines-repro && cd /tmp/devengines-repro
printf '%s' '{ "devEngines": { "packageManager": { "name": "pnpm" } } }' > package.json
npx -y cowsay hi
npm config get registry
Both commands exit 1. Neither installs anything, neither reads a lockfile, and npm config get registry does not touch the project at all: it prints a config value. This is the repro from #10301, reduced. Keep the directory, since the later steps mutate only package.json.
2. Line three tells you which fault you have
EBADDEVENGINES is one code covering five distinct faults, and the discriminator is the third line of output. The strings come from checkDependency in npm-install-checks 9.0.0 (lib/dev-engines.js).
Invalid devEngines.runtime on line two means the runtime block failed, compared against process.version rather than against anything npm-specific, so it is a real Node mismatch and your Node version is the thing to change. Invalid property "devEngines.packageManagers" means an unrecognized engine key: checkDevEngines throws on that path instead of returning a failure, so it arrives without the EBADDEVENGINES code. Of the three line-three forms, Invalid name is a string comparison you cannot win (step 3), Invalid semver version means your npm falls outside a valid range and a newer npm satisfies it, and Invalid version means the pinned range is not valid semver at all, in which case the checker falls back to comparing the two strings exactly.
3. Why Invalid name "pnpm" cannot be fixed
currentEnv.devEngines() in lib/current-env.js does not detect the running package manager. It asserts one:
packageManager: {
name: 'npm',
version: env.npmVersion,
},
runtime: {
name: 'node',
version: env.nodeVersion || process.version,
},
checkDependency then evaluates wanted.name !== current.name. A repo pinning "name": "pnpm" fails by construction under npm, at every version. Upgrading npm, clearing the cache and deleting node_modules change nothing, because the comparison is a string literal against a string literal.
4. Find the gate: a static flag nobody reads
Two states hold at once that should not. exec, which is what npx runs, declares that it does not want the check, and npx throws it anyway. The two artifacts sit two files apart. From lib/base-cmd.js:
class BaseCommand {
// these defaults can be overridden by individual commands
static workspaces = false
static ignoreImplicitWorkspace = true
static checkDevEngines = false
lib/commands/exec.js never overrides that default. lib/commands/run.js and lib/arborist-cmd.js (the parent of install and ci) each carry static checkDevEngines = true, which matches the documented scope exactly. Then lib/npm.js:
// Check dev engines if needed
if (commandInstance.checkDevEngines && !this.global) {
await commandInstance.checkDevEngines()
}
The condition reads commandInstance.checkDevEngines, the instance property, which resolves to the async checkDevEngines () method on BaseCommand's prototype. A function is truthy, so the static opt-in has never been consulted and every command reaching execCommandClass runs the check. PR #10302 swaps in Command.checkDevEngines, and its test asserts that npm.exec('prefix') stays clean while npm.exec('run') still rejects.
5. Note the !this.global escape hatch
That same line exempts every global command, so npm install -g npm@12 is not gated. The advice in the setup-node thread treats npm as validating engines before any command and concludes that upgrading npm afterward cannot help. Per the source, the upgrade command itself is exempt. What fails there is npm config get cache, which setup-node runs inside the action before your upgrade step starts, so the fix is step ordering. Worth stating plainly: because --global skips the check entirely, devEngines is a convention rather than a control.
6. Pick the fix by scope
| Fix | Where it lives | Keeps the pin enforced on install/ci/run | Affects teammates | Use when |
|---|---|---|---|---|
"onFail": "warn" | package.json, committed | No, downgraded to npm warn everywhere | Yes | The repo must stay usable from npm |
"onFail": "ignore" | package.json, committed | No, silent, nothing logged | Yes | Last resort, see pitfalls |
--prefix <empty dir> | One invocation | Yes | No | One-off npx in a pinned repo |
npm install -g npm@<range> | Machine or image | Yes | No | Line three says Invalid semver version |
--force / npm_config_force=true | One invocation | Yes, elsewhere | No | Nothing else fits and you accept the blast radius |
--prefix works because checkDevEngines reads this.npm.config.localPrefix. Point it at a directory with no package.json and the check short-circuits on typeof devEngines === 'undefined'.
Verify it works
Decide which commands are gated by probing, not by reading release notes. I learned that the expensive way on a Node patch day earlier this year, where the version string lied and only a behavioural check gave the real answer. Two runs, one changed value. Start from the version-mismatch form:
printf '%s' '{ "devEngines": { "packageManager": { "name": "npm", "version": "^99.0.0" } } }' > package.json
npm config get registry; echo "exit=$?"
Expect Invalid semver version "^99.0.0" does not match "12.2.3" for "packageManager" and exit=1. Now change one flag and nothing else:
npm config get registry --global; echo "exit=$?"
Expect the registry URL and exit=0. That pair demonstrates the !this.global branch instead of inferring it, and it rules out your npm version as the cause. Add "onFail": "warn" to the same object and run the first command again to see npm warn EBADDEVENGINES with a zero exit, because the warning path in base-cmd.js logs and falls through.
Common pitfalls
onFail is read from the last array entry only. When devEngines.packageManager is an array, checkDevEngines takes const lastDependency = dependencies[dependencies.length - 1] and then let onFail = lastDependency.onFail || 'error'. Putting onFail: "warn" on the first entry of [{ "name": "pnpm", "onFail": "warn" }, { "name": "yarn" }] does nothing, because the governing value comes from { "name": "yarn" }, which has none, so the 'error' default applies. This behaviour is in the source and in no documentation.
Arrays pass if any entry matches. The engine is flagged only when depErrors.length === dependencies.length, so "packageManager": [{ "name": "pnpm" }, { "name": "npm" }] passes under both tools. That is the cleanest way to keep a pnpm pin without breaking npx for anyone who types it.
onFail: "download" is an error, not a download. It appears in recognizedOnFail, and three lines later if (onFail === 'download') { onFail = 'error' }. npm has no download path behind it.
onFail: "ignore" is silent rather than skipped. The failure is still pushed into the returned array with both isWarn and isError false, and base-cmd.js filters on those two flags, so nothing logs and nothing throws. The pin becomes invisible instead of relaxed.
A typo in the engine key produces a different error. checkDevEngines throws Invalid property "devEngines.packageManagers" for an unrecognized key, as it does for a missing name or a non-string onFail. Those propagate without the EBADDEVENGINES code, so a CI log grep for the code misses them.
--force is wider than this one check. npm's config documentation describes force as removing "various protections against unfortunate side effects, common mistakes, unnecessary performance degradation, and malicious input", and on npm 12 that includes the install-script guards, whose own failure modes are covered in 10 checks for allowScripts. Reportedly, a setup-node maintainer rejected a proposed --force workaround in November on the narrower version of the same objection, that it changes npm's handling of all devEngines mismatches for that invocation.
One row I could not pin to a release. npm 10.9.3 printed Invalid engine "packageManager" where 10.9.7 and later print Invalid devEngines.packageManager, and the npm-install-checks changelog lists only "update error message for checkDevEngines (#128)" at 7.1.2 (25 August 2025) without quoting either string. The command that settles it is npm pack npm-install-checks@7.1.1, then tar -xOzf npm-install-checks-7.1.1.tgz package/lib/dev-engines.js | grep -n 'Invalid engine'. If you are searching the older string you are on an older npm, and the fix table above is unchanged either way.
Wrap-up
Two things to do next. Add { "name": "npm" } as a second array entry if you want a pnpm pin that leaves npx working, and watch PR #10302, after which npm config, npm view and npx stop checking and only install, ci and run remain gated. Until it merges, assume every non-global npm command in a pinned repo is gated, then confirm it for your own version:
npm config get registry; echo "exit=$?"
Comments
Be the first to comment.