npm 12 turned an unknown name on the command line into a hard EUNKNOWNCONFIG failure, while the same name in .npmrc, in npm_config_*, or in publishConfig still only warns. Which of those four sources npm read decides the fix: delete the flag, move it after --, export it as an environment variable, or upgrade the build plugin that appended it without telling you. This guide reproduces all four, and ends with a sweep that diffs your own invocations against the names npm 12 actually knows.
Prerequisites
- npm 12.x (
npm --version). 12.2.2, dated 2026-11-03 in the v12 changelog, is the newest 12 line at the time of writing. - An npm 11.x for the control run. Use
npx npm@11.19.0 …rather than switching the global install. This one step needs network access. - Node 22 or newer and a scratch directory with a throwaway manifest (
npm init -y). Everything below is registry-free apart from the control run. - Read access to your CI definitions and to any JVM plugin that shells out to npm: Vaadin Flow's
build-frontend, the Spotless Gradle plugin running Prettier, or Nx/Rush/Lerna wrappers.
Reproduce it twice, changing only the npm major
1. Pass a flag npm has never had.
npm install --no-audit --bogus-flag
The command exits non-zero and prints the error code, the Unknown cli flag: line, the offending name on its own indented line, and a pointer to npm help config. The reported shape, quoted from npm/cli issue #10023 (opened 23 September 2026 against npm 12.1.0, closed 6 November 2026), is:
npm error code EUNKNOWNCONFIG
npm error Unknown cli flag:
npm error - --build-from-source
npm error Run `npm help config` for supported options.
2. Run the same command on npm 11.
npx npm@11.19.0 install --no-audit --bogus-flag
npm 11 warns about the unknown config and installs anyway. The change is PR #9276, "feat!: error on unknown configs, flags, and abbreviations", merged 21 May 2026, which names four newly fatal categories: unknown .npmrc keys, unknown CLI flags, abbreviated flags such as --dry for --dry-run, and single-hyphen multi-character flags such as -longflag.
3. Put the identical name in a file config.
printf 'bogus-flag=true\n' >> .npmrc
npm install --no-audit
This warns and installs. PR #9729, merged 8 July 2026, reverted the file-config half of #9276 before 12.0.0 stable shipped. Its warning text is assembled at runtime from the config's where and display name, so read the rendered line from your own terminal rather than from a quoted string. The practical consequence: the .npmrc cleanup that most assistants suggest first was never what failed. Where npm config legitimately lives in a manifest is a separate question, covered under allowScripts.
Which of four places did npm read that flag from?
| Where npm read the name | npm 11 | npm 12.2.2 | How to make it error |
|---|---|---|---|
CLI flag --bogus-flag | warn | EUNKNOWNCONFIG, exit non-zero | already fatal, no opt-out |
.npmrc (project/user/global/builtin) | warn | warn | strict-npmrc=true |
env npm_config_bogus_flag | warn | warn | none today |
publishConfig in package.json | warn | warn | none today |
Why npm config set says the name is fine
PR #9276 exempts five commands from validation through static skipConfigValidation = true: config, help, doctor, completion and version.
npm config set scripts-prepend-node-path true
npm config get scripts-prepend-node-path
Both succeed, and the next npm install is still the command that dies. "I checked with npm config" is a false negative, and it is worth saying out loud to whoever filed the ticket.
The flag you never typed: who passes it for you
Four named cases, each with its own fix:
- Vaadin Flow appended
--scripts-prepend-node-path=trueto everynpm installissued bybuild-frontend. A 26 August 2026 forum report shows it failing on Vaadin 25.2.6 with npm 12.0.2. Flow PR #25333 removed the flag fromFrontendTools#getNpmExecutable, and the 25.2.8 release note points out that Flow requires npm 11.3 or newer, so no supported npm honoured the flag anyway. - Spotless (Gradle) reaches the same flag through Prettier. testcontainers-java issue #11997, opened 28 August 2026, fails at
:test-support:spotlessJava; the reporter confirms the upstream fix in Spotless 8.10.1 (diffplug/spotless#3024). - pnpm forwarding
--git-checksand--config.fetch-retriesinto an npm child process, which npm 11 only warned about. - CITGM passing
--build-from-sourcefor native builds, which is the npm/cli#10023 report above. Thenode-pre-gypbehaviour it wanted still works throughnpm_config_build_from_source. Native rebuilds on npm 12 have a second, unrelated trap in the bundled node-gyp 12.
npm run dev --port 3000 is a failed build now
npm run dev --port 3000
npm parses argv before the -- separator as its own config, so --port was always a flag npm swallowed instead of forwarding. On npm 11 that produced a warning and a developer wondering why the port never changed. On npm 12 it produces EUNKNOWNCONFIG and a red pipeline.
npm run dev -- --port 3000
The separator fixes npm's half. The script still has to read the argument, so if your dev script ignores process.argv, moving the flag changes nothing visible.
Moving the flag into the environment buys you one major version
npm_config_build_from_source=true npm install --no-audit
Dashes become underscores, and npm 12 accepts the unknown environment config with a warning that it will stop working later. The exact wording is the one row here I cannot pin: reports quote both This will error in a future major version of npm. (attributed to npm 12.2.0) and This will stop working in the next major version of npm., and no npm/cli release note names npm 13 as the version that promotes the warning to an error. Settle it on your own install before you build a policy on it:
npm_config_bogus_flag=1 npm install --no-audit 2>&1 | grep -i 'env config'
The shorthands that stopped expanding
Abbreviations were convenience behaviour that npm 11 resolved silently, and #9276 removed them along with the unknown names. --dry no longer reaches --dry-run, -longflag is no longer read as --longflag, and -j no longer expands to --json. Each one now reports as an unknown CLI flag, which makes a grep for EUNKNOWNCONFIG in CI logs pick up typos and abbreviations in the same pass.
strict-npmrc, and the auth keys that must move
Set the opt-in once, in CI, so file configs fail at the same volume as flags:
npm config set strict-npmrc true --location=project
Before you turn it on, move legacy top-level auth keys into scoped (nerf-dart) form. #9276 requires email, _authToken, _password, username, certfile and keyfile to be registry-scoped; a top-level copy counts as an unknown config. The same opt-in-strictness pattern shows up in the install-script gate behind ESTRICTALLOWSCRIPTS.
Verify it works
npm install --no-audit --dry; echo "exit=$?"
Expect EUNKNOWNCONFIG naming --dry and exit=1. Then prove the abbreviation was the cause rather than the command:
npm install --no-audit --dry-run; echo "exit=$?"
Expect exit=0. Two runs, one changed character, and the difference is the whole claim.
Common pitfalls
- Pinning npm 11 hides a plugin that is already fixed.
npm install -g npm@11is the top circulating workaround and it does work. It also parks the build on an npm major without the 12 install-script defaults, and both JVM cases have upstream releases (Flow 25.2.8, Spotless 8.10.1). - Trusting the v12.0.0 GitHub release notes. They stated that unknown
.npmrckeys throw. Doc issue #9812 sat open from 28 July to 28 October 2026 before the tag was edited; the CHANGELOG entry for 12.0.0 (2026-07-08) is the accurate one, and 12.0.2's docs section records the correction as #9805. - Alpine plus Vaadin is a different failure. A glibc Node binary on musl produces
Cannot run program …/bin/node, which has nothing to do with flag validation. Keep the two tickets apart. - Chasing the error into
.npmrcbecause the error text mentions config. The code isEUNKNOWNCONFIGfor all four sources, and only argv exits non-zero.
FAQ
Does npm 12 fail on unknown keys in .npmrc? No. PR #9729 reverted that half before 12.0.0 stable, so file configs warn. The v12.0.0 release notes claimed otherwise until October 2026.
How do I pass a flag to my script rather than to npm? Put it after --. npm treats argv before the separator as its own config.
Is npm_config_<name> safe long term? It is a bridge for a tool you cannot patch. npm 12 warns and says the behaviour goes away in a future major.
Why did npm config set accept a name that breaks npm install? Five commands set skipConfigValidation = true, and config is one of them.
Wrap-up
Run the sweep before your next npm bump instead of after it. Enumerate the names npm 12 knows:
npm config ls -l --json > /tmp/npm-known.json
Then collect every flag your repo actually passes, including the ones buried in build files:
grep -rhoE '\-\-[a-z][a-z0-9-]+' package.json .github/workflows pom.xml build.gradle 2>/dev/null | sort -u > /tmp/npm-flags.txt
Diff the two lists, and treat anything in the second that is missing from the first as a build that is one upgrade away from exit 1.
Comments
Be the first to comment.