Tool pages / npm CLI
npm CLI 12.2.0: latest version, breaking changes and gotchas
Latest: npm CLI 12.2.0, released (release notes).
The latest npm CLI (npm, repo npm/cli) is 12.2.0, released 2026-09-30 16:47 UTC (published to the npm registry at 16:46 UTC). Upgrade with npm i -g npm@latest or npm i -g npm@12.2.0. Node.js 26 LTS (v26.11.0, 2026-10-07) bundles npm 11.20.0, so environments vary between npm 11 and npm 12. In npm 12, dependency lifecycle scripts are blocked by default unless granted in allowScripts or allowed via --allow-scripts=<pkg>, allow-git and allow-remote default to none, npm patch was added, and unknown flags or single-hyphen shorthands throw EUNKNOWNCONFIG.
How do I install or upgrade to npm CLI 12.2.0?
Upgrade to latest npm:
npm i -g npm@latest
npm --version # 12.2.0Pin npm 12 latest:
npm i -g npm@12.2.0Stay on npm 11 (Node 26 LTS line):
npm i -g npm@11.20.0Using Homebrew (macOS / Linux):
brew install nodeAllow dependency install scripts on global install (npm 12):
npm i -g --allow-scripts=<pkg> <pkg>
# or set permanently for user:
npm config set allow-scripts=<pkg> --location=usernpm CLI key facts
- Latest release: 12.2.0 on 2026-09-30 16:47 UTC (GitHub tag
v12.2.0; npm publish 16:46 UTC). Previous release on the v12 line: 12.1.0 on 2026-09-22 20:21 UTC. - Node.js 26 LTS (v26.11.0, released 2026-10-07) bundles npm 11.20.0, not npm 12. Agents running in freshly spawned Node 26 containers encounter npm 11 by default, while environments running
npm i -g npm@latestrun npm 12. - npm 12 requires Node.js
^22.22.2 || ^24.15.0 || >=26.0.0(engines.nodeinpackage.json). Node 20 is no longer supported in npm 12 (npm 11 supported^20.17.0 || >=22.9.0). - Lifecycle scripts blocked by default: npm 12 blocks dependency
preinstall,install, andpostinstallscripts unless authorized inallowScriptsinpackage.jsonor bypassed with--allow-scripts=<pkg>. Global installs print a warning and suggestnpm config set allow-scripts=<pkg> --location=user. - Git and remote tarball dependencies disabled:
allow-gitandallow-remotedefault tononein npm 12 (changed fromallin npm 11). Dependencies from git URLs throwEALLOWGIT; remote tarball URLs throwEALLOWREMOTE. Setallow-git=allorallow-remote=allin.npmrcto restore npm 11 behaviour. - Strict CLI flag validation: unknown CLI flags, single-hyphen multi-char flags (like
-flaginstead of--flag), and abbreviated flags throwEUNKNOWNCONFIGin npm 12 instead of merely warning. - Authoritative command count: 68 commands in npm 12.2.0 vs 72 commands in npm 11.20.0. npm 12 added
npm patch(add,commit,update,ls,rm) and removed 5 deprecated commands:npm adduser(usenpm login),npm shrinkwrap,npm star,npm stars,npm unstar. - npm 12.1.0 introduced
read-write-stage-onlyas an option for--packages-and-scopes-permissioninnpm token create, warning that bypass-2fa direct-publish tokens will stop working in January 2027 in favour of staged releases vianpm stage. - 19,571,278 weekly downloads on the npm registry in the week 2026-09-28 to 2026-10-04; 10,174 GitHub stars and Artistic-2.0 licence on 2026-10-07.
What changed in the last 5 npm CLI releases?
npm CLI 12.2.0 (2026-09-30 16:47 UTC)
npm CLI 11.20.0 (2026-09-22 21:34 UTC)
- token: backport support for read-write-stage-only granular access tokens (
lib/commands/token.js, PR #9994). (source) - stage: display staged package status in stage command (
lib/commands/stage/index.js, PR #9920). (source) - provenance-file takes precedence over OIDC auto-generated provenance (PR #9947). (source)
npm CLI 12.1.0 (2026-09-22 20:21 UTC)
- token: support read-write-stage-only granular access tokens and warn on direct-publish tokens (
lib/commands/token.js, PR #9948). (source) - stage: display staged package status in stage command (
lib/commands/stage/index.js, PR #9898). (source) - provenance-file config takes precedence over OIDC auto-generated provenance (PR #9882). (source)
- arborist: reject uninstall arguments that carry a version specification (
lib/commands/uninstall.js, PR #9881). (source)
npm CLI 11.19.1 (2026-08-26 21:48 UTC)
npm CLI 12.0.2 (2026-07-29 21:11 UTC)
Which npm CLI commands and flags were added or removed?
npm CLI 12.1.0 → 12.2.0
0 commands added, 0 removed, 0 commands with flags added or removed; 0 help pages changed.
Method: From source (not run): compared git tree and command definitions in lib/commands/ and workspaces/config between v12.1.0 and v12.2.0. No command or flag was added or removed.
- The last two releases on the npm 12 line. 12.2.0 added OIDC authentication handling to
npm dist-tagand updated documentation fornpm stagewithout altering the visible CLI surface.
npm CLI 11.20.0 → 12.2.0
1 command added, 5 removed, 1 command with flags added; 6 command surfaces changed.
Method: From source (not run): compared command definitions in lib/commands/, lib/utils/cmd-list.js, and workspaces/config between v11.20.0 (the newest npm 11 release) and v12.2.0 (the newest npm 12 release).
Commands added:
npm patch
Commands removed:
npm addusernpm shrinkwrapnpm starnpm starsnpm unstar
| Command | Flags added | Flags removed |
|---|---|---|
npm patch | --allow-unused-patches--edit-dir--ignore-existing--ignore-patch-failures--keep-edit-dir--patches-dir--registry--to | none |
- Compares the active npm 11 and npm 12 lines.
npm patchwas introduced in npm 12 to create and manage local dependency patches inpatchedDependencies. Five legacy commands (adduser,shrinkwrap,star,stars,unstar) were removed.
npm CLI 12.0.2 → 12.1.0
0 commands added, 0 removed, 0 commands with flags added or removed; 0 help pages changed.
Method: From source (not run): compared command definitions and config definitions in workspaces/config between v12.0.2 and v12.1.0.
- 12.1.0 added the
read-write-stage-onlypermission value to--packages-and-scopes-permissionfornpm token create, and added precedence handling forprovenance-file.
npm CLI 11.18.0 → 12.0.0
1 command added, 5 removed, 1 command with flags added; 6 command surfaces changed.
Method: From source (not run): compared command definitions in lib/commands/, lib/utils/cmd-list.js, and workspaces/config between v11.18.0 and v12.0.0.
Commands added:
npm patch
Commands removed:
npm addusernpm shrinkwrapnpm starnpm starsnpm unstar
| Command | Flags added | Flags removed |
|---|---|---|
npm patch | --allow-unused-patches--edit-dir--ignore-existing--ignore-patch-failures--keep-edit-dir--patches-dir--registry--to | none |
- The major jump to npm 12. Added
npm patch(add,commit,update,ls,rm) with dedicated patching flags. Removednpm adduser,npm shrinkwrap,npm star,npm stars, andnpm unstar. Note thatnpm install-scriptsandnpm stagewere introduced in late v11 in preparation for npm 12.
What breaks when upgrading npm CLI, and how do I migrate?
| Version | Change | Migration |
|---|---|---|
| 12.0.0 | Dependency lifecycle scripts (preinstall, install, postinstall) are blocked by default unless authorized by the root package's allowScripts policy. | Run npm install-scripts approve <pkg> to approve in a project's package.json, or pass --allow-scripts=<pkg> (e.g. npm i -g --allow-scripts=foo foo). For global installs, configure once with npm config set allow-scripts=<pkg> --location=user. |
| 12.0.0 | allow-git and allow-remote now default to 'none' (previously 'all'). Installing from git repositories or direct tarball URLs fails with EALLOWGIT or EALLOWREMOTE. | Set allow-git=all and allow-remote=all in .npmrc or pass --allow-git=all / --allow-remote=all on the command line if your project relies on git or remote tarball dependencies. |
| 12.0.0 | Unknown flags on the command line, unknown configs in .npmrc when strict-npmrc is set, single-hyphen multi-character shorthands (-flag), and abbreviated flags throw EUNKNOWNCONFIG instead of warning. | Replace single-hyphen flags with double-hyphen flags (e.g. --save not -save), expand abbreviated flags to full names, and run npm help config to remove unrecognized options from .npmrc. |
| 12.0.0 | Legacy commands npm adduser, npm shrinkwrap, npm star, npm stars, and npm unstar were removed. npm view --json now always outputs an array. | Use npm login instead of npm adduser. Use package-lock.json instead of npm-shrinkwrap.json. Manage package stars on npmjs.com. In scripts parsing npm view --json, expect an array even for single version results. |
| 12.0.0 | Minimum supported Node.js version raised to ^22.22.2 || ^24.15.0 || >=26.0.0. Node 20 is no longer supported. | Upgrade the runtime environment to Node.js 22.22.2+, 24.15.0+, or 26.0.0+ before upgrading to npm 12. |
What npm CLI errors did we reproduce, and how do I fix them?
npm 12 blocks dependency postinstall scripts during installation (npm CLI 12.2.0)
npm i -g opencode-ai@1.18.35npm warn install-scripts 1 package had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts opencode-ai@1.18.35 (postinstall: node ./postinstall.mjs)
npm warn install-scripts Run `npm install -g --allow-scripts=opencode-ai` to allow these scripts once, or `npm config set allow-scripts=opencode-ai --location=user` to allow them for all global installs.
# Note: install exits 0, but binary subsequently fails because postinstall was not runFix: Install with npm i -g --allow-scripts=opencode-ai opencode-ai@latest, or configure once via npm config set allow-scripts=opencode-ai --location=user. In local projects, approve using npm install-scripts approve <pkg> followed by npm rebuild. (source)
Git dependencies fail with EALLOWGIT because allow-git defaults to none (npm CLI 12.2.0)
npm install git+https://github.com/user/repo.gitnpm error code EALLOWGIT
npm error Fetching packages of type "git" have been disabled
# exit 1 (quoted from workspaces/arborist/lib/arborist/build-ideal-tree.js line 852 at v12.2.0)Fix: Run npm install --allow-git=all git+https://github.com/user/repo.git or set allow-git=all in project .npmrc (or allow-git=root if git deps are only declared in top-level package.json). (source)
Remote tarball dependencies fail with EALLOWREMOTE because allow-remote defaults to none (npm CLI 12.2.0)
npm install https://example.com/package.tgznpm error code EALLOWREMOTE
npm error Fetching packages of type "remote" have been disabled
# exit 1 (quoted from workspaces/arborist/lib/arborist/build-ideal-tree.js line 852 at v12.2.0)Fix: Run npm install --allow-remote=all https://example.com/package.tgz or set allow-remote=all in .npmrc. (source)
Single-hyphen multi-character flags throw EUNKNOWNCONFIG (npm CLI 12.2.0)
npm install -save-dev lodashnpm error code EUNKNOWNCONFIG
npm error -save-dev is not a valid single-hyphen cli flag. Did you mean --save-dev?
# exit 1 (quoted from workspaces/config/lib/index.js line 387 at v12.2.0)Fix: Use standard double hyphens for multi-character options: npm install --save-dev lodash (or short single flags like -D). (source)
Invalid abbreviated CLI flags throw EUNKNOWNCONFIG (npm CLI 12.2.0)
npm install --sav lodashnpm error code EUNKNOWNCONFIG
npm error Invalid abbreviated flag "--sav". Did you mean "--save"?
# exit 1 (quoted from workspaces/config/lib/index.js line 597 at v12.2.0)Fix: Specify the full flag name: --save or --save-dev. Abbreviated flag resolution was disabled in npm 12. (source)
Removed commands like npm adduser fail with EUNKNOWNCOMMAND (npm CLI 12.2.0)
npm addusernpm error code EUNKNOWNCOMMAND
npm error Unknown command adduser
# exit 1 (quoted from lib/npm.js line 23 at v12.2.0)Fix: Use npm login to authenticate on the command line. Account registration and user creation must now be done on https://www.npmjs.com. (source)
npm CLI release history by month
2026-10: 12.2.0 (0 releases to 2026-10-07)
- 12.2.0 (2026-09-30) active: Node 26 LTS bundles npm 11.20.0, while standalone installs run npm 12.2.0. (source)
2026-09: 11.20.0 to 12.2.0 (3 releases)
2026-08: 11.19.1 (1 release)
- 11.19.1: exempt explicit pack directory targets from allow-directory restriction; dependencies updated (tar@7.5.22, undici@6.28.0). (source)
2026-07: 10.9.9 to 12.0.2 (5 releases)
- 12.0.0 (2026-07-08): major release! Block dependency lifecycle scripts by default (allowScripts); allow-git and allow-remote default to none; npm patch added; removed adduser/shrinkwrap/star. (source)
- 12.0.2 & 11.19.0: pack honors min-release-age-exclude; scoped registry for owner user lookup. (source)
2026-06: 11.17.0 to 11.18.0 (2 releases)
2026-05: 11.14.0 to 11.16.0 (4 releases)
Sources
- npm 12.2.0 release on GitHub (read 2026-10-07)
- npm 12.2.0 release on npm registry (read 2026-10-07)
- npm 12.1.0 release on GitHub (read 2026-10-07)
- npm 11.20.0 release on GitHub (read 2026-10-07)
- npm 11.19.1 release on GitHub (read 2026-10-07)
- npm 12.0.2 release on GitHub (read 2026-10-07)
- npm 11.19.0 release on GitHub (read 2026-10-07)
- npm 10.9.9 release on GitHub (read 2026-10-07)
- npm 12.0.1 release on GitHub (read 2026-10-07)
- npm 12.0.0 release on GitHub (read 2026-10-07)
- npm 11.18.0 release on GitHub (read 2026-10-07)
- npm 11.17.0 release on GitHub (read 2026-10-07)
- PR #10038: dist-tag: support OIDC authentication (read 2026-10-07)
- PR #10017: update npm stage docs to reflect that it can create new packages (read 2026-10-07)
- PR #9948: token: support read-write-stage-only granular access tokens (read 2026-10-07)
- PR #9898: stage: display staged package status (read 2026-10-07)
- PR #9882: provenance-file takes precedence over OIDC auto-generated provenance (read 2026-10-07)
- PR #9913: config: avoid exporting persistent allow-scripts (read 2026-10-07)
- PR #9914: arborist: match allowScripts keys for local paths (read 2026-10-07)
- PR #9760: pack: honor min-release-age-exclude (read 2026-10-07)
- PR #9786: owner: use scoped registry for user lookup (read 2026-10-07)
- PR #9805: clarify npm 12 unknown-config breaking change in changelogs (read 2026-10-07)
- PR #9745: view: avoid wrapping array results (read 2026-10-07)
- GitHub Changelog: Upcoming breaking changes for npm v12 (read 2026-10-07)
- Node.js releases and bundled npm versions index (read 2026-10-07)
- npm registry weekly download statistics (read 2026-10-07)
- npm/cli repository metadata (stars, license) (read 2026-10-07)
- npm package.json at v12.2.0 (engines, license) (read 2026-10-07)
- npm lib/commands/patch.js at v12.2.0 (read 2026-10-07)
- npm lib/commands/install-scripts.js at v12.2.0 (read 2026-10-07)
- npm lib/utils/reify-output.js at v12.2.0 (unreviewedScripts warning) (read 2026-10-07)
- npm lib/utils/check-allow-scripts.js at v12.2.0 (read 2026-10-07)
- npm lib/utils/allow-scripts-remediation.js at v12.2.0 (read 2026-10-07)
- npm lib/utils/cmd-list.js at v12.2.0 (authoritative commands) (read 2026-10-07)
- npm lib/base-cmd.js at v12.2.0 (validateCli, EUNKNOWNCONFIG) (read 2026-10-07)
- npm workspaces/config/lib/index.js at v12.2.0 (read 2026-10-07)
- npm workspaces/config definitions at v12.2.0 (allow-git, allow-remote, strict-npmrc) (read 2026-10-07)
- npm workspaces/arborist build-ideal-tree.js at v12.2.0 (#checkAllow, EALLOWGIT, EALLOWREMOTE) (read 2026-10-07)
Last verified: 2026-10-07.