Preparing for npm v12: install scripts and non-registry sources become opt-in #198547
-
|
Hi everyone — sharing this so maintainers, application developers, and CI operators have time to prepare for behavioral changes landing in npm v12 (estimated July 2026). Everything below is already available in npm 11.16.0 so you can migrate today. What is changing in v12Three
Most of this post focuses on install scripts, since that's the migration with the most moving parts. Why install scriptsInstall-time lifecycle scripts are the single largest code-execution surface in the npm ecosystem. Every The commands
By default, Recommended first step: allow what you already haveIf you're adopting this on an existing project, the fastest safe migration is to allow everything currently in your tree first, then tighten later — rather than agonizing over each package and delaying rollout: npm install # warns about packages with skipped scripts
npm approve-scripts --allow-scripts-pending # review the list
npm approve-scripts --all # approve everything currently pending
git add package.json && git commit -m "chore: snapshot current install-script allowlist"This gets you protected against new, unexpected scripts immediately. You can then "If you have X, do Y" — migration recipesNative modules (anything built on
|
| Version | Date | Behavior |
|---|---|---|
| npm 11.16.0 | Available now | Features available; warnings by default; opt into enforcement with strict-allow-scripts |
| npm 12 | Estimated July 2026 | allowScripts off by default; --allow-git and --allow-remote default to none |
How to get help
- General questions and discussion: reply in this thread.
- Bugs or regressions: npm/cli issues, tag
allowScripts. - Maintainers of high-impact packages: open an issue in npm/cli tagged
maintainer-outreach. - Enterprise customers: contact your GitHub or Microsoft account team.
References
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 20 replies
This comment has been hidden.
This comment has been hidden.
-
|
Will Node 26 eventually ship with npm 12? Or will that wait until Node 27? |
Beta Was this translation helpful? Give feedback.
-
|
Would’ve been nice with a default min package age too👍 |
Beta Was this translation helpful? Give feedback.
-
|
There should be a way out of ignore-scripts, while keeping it for NPM < 11.16.0 In a shared CI environment, we set a global |
Beta Was this translation helpful? Give feedback.
-
|
What is the recommended way to install new packages that include scripts? Current behaviour when Am I missing something? |
Beta Was this translation helpful? Give feedback.
-
|
Does the allow hash the allowed scripts and npm compare hash before running? Is this just accept package x's {type of script} and if changed could still just run arbitrary code on an update? If version matching then does npm disallow version delete and republish same version? If not then there is a hole of I replace version 1.2 version with a new bad version. You accepted that version range and I snuck something different in. |
Beta Was this translation helpful? Give feedback.
-
|
strict-allow-scripts is not the v12 default and won't be. The v12 default is softer: an install script you haven't approved gets skipped, you get a warning, and the install still succeeds. So npm install -D esbuild just works. esbuild lands in node_modules, its postinstall is skipped, you see a warning saying so. No failure, and no chicken-and-egg. The wall is coming entirely from strict-allow-scripts=true. That turns the skip into a hard error that fires before npm writes anything, so esbuild never gets installed. That's why approve-scripts esbuild can't find it afterward. There's nothing on disk to approve yet. The other two are doing what they should. --allow-scripts is blocked in project installs on purpose (it's for -g and npx), and --dangerously-allow-all-scripts skips the whole policy by design. So I'd just not run strict on your dev machine. Keep it in CI, where the package is already in package.json and already approved. Locally: npm install -D esbuild # installs; postinstall skipped + warning Commit the package.json and CI passes, because esbuild is now covered. If you really want strict locally too, add new packages with --no-strict-allow-scripts for that one command, then approve and rebuild. |
Beta Was this translation helpful? Give feedback.
strict-allow-scriptsis not the v12 default and won't be. The v12 default is softer: an install script you haven't approved gets skipped, you get a warning, and the install still succeeds. Sonpm install -D esbuildjust works. esbuild lands innode_modules, itspostinstallis skipped, you see a warning saying so. No failure, and no chicken-and-egg.The wall is coming entirely from
strict-allow-scripts=true. That turns the skip into a hard error that fires before npm writes anything, so esbuild never gets installed. That's whyapprove-scripts esbuildcan't find it afterward. There's nothing on disk to approve yet.The other two are doing what they should.
--allow-scriptsis blocked in proj…