GitHub announced yesterday the breaking changes coming in npm v12. The release is estimated for July 2026, so about a month away. And this one is big. It changes what npm install actually does, for everyone.
Short version: npm will stop trusting your dependencies by default. Install scripts, git dependencies and remote tarball dependencies will all be blocked unless you allow them explicitly.
This is the right move and it is long overdue. But it will break builds for many teams who don’t prepare. Let’s go through it.
What happens today
When you run npm install today, three things happen automatically that most people never think about:
1. Lifecycle scripts run. Any package in your dependency tree can define preinstall, install or postinstall scripts. These are just shell commands, and npm runs them on your machine during install. All of them. From every package in the tree, not only the ones you picked yourself.
2. Git dependencies get resolved. If some package in the tree points to a git repo as a dependency, npm clones and installs it.
3. Remote URL dependencies get resolved. Same for dependencies that point at a https tarball somewhere on the internet.
This is exactly why npm supply chain attacks work so well. An attacker compromises one package, adds a postinstall script that steals tokens, and every developer and CI runner that installs it executes the malware. No click needed, no warning. We saw it in the AntV attack last month, where 323 poisoned packages went out in 22 minutes. The install script is the delivery mechanism in almost every npm attack.
What will happen in v12
npm v12 turns all three behaviors from automatic into opt-in.
1. Install scripts blocked by default
npm install will no longer run preinstall, install or postinstall scripts from dependencies. You have to allow each package explicitly.
Two details here that will surprise people:
- Native builds are blocked too. A package with a
binding.gypfile and no install script still gets blocked, because npm runs an implicitnode-gyp rebuildfor it. So native modules likebcryptorsqlite3will not compile unless you approve them. preparescripts from git, file and link dependencies are blocked the same way.
npm gives you new commands to manage this:
# see which packages want to run scripts
npm approve-scripts --allow-scripts-pending
# allow the ones you trust
npm approve-scripts <package>
# block the rest
npm deny-scripts <package>
The allowlist gets written into your package.json. Commit it. From then on, your whole team and your CI run the same policy.
2. Git dependencies blocked by default
npm install will not resolve git dependencies anymore, direct or transitive, unless you pass --allow-git.
The reason is interesting. A git dependency can carry its own .npmrc file, and that file can override which git executable npm calls. That means code execution even if you installed with --ignore-scripts. So the old advice “just use ignore-scripts” was never fully safe. This change closes that hole.
3. Remote tarball dependencies blocked by default
Same logic. Dependencies that point at remote URLs like https tarballs will not resolve unless you pass --allow-remote. The --allow-file and --allow-directory flags exist too but their defaults are not changing in v12.
What it means
For attackers, the free ride is ending. Publishing a poisoned package will not give automatic code execution on thousands of machines anymore. The most common npm attack path just got a door put in front of it.
For you, it means npm install becomes a bit more work. Most packages don’t run any scripts at all, so most projects will need to approve only a handful. Typical suspects are native modules, packages like esbuild that download binaries in postinstall, and husky style git hook tools.
For the ecosystem, expect a messy month or two. Some maintainers will move away from install scripts. Some CI setups will break loudly. Then it settles, like it always does.
The complexities nobody will tell you about
A few things to watch out for:
- Failures can be quiet. A blocked native build doesn’t always fail at install time. Sometimes it fails later, at runtime, when the module is missing. Test your app after the upgrade, not just the install.
- Transitive dependencies count. The scripts you need to approve are not only from your direct dependencies. Something five levels deep in the tree can be the one that needs node-gyp.
- CI images lag behind. Your laptop may run npm 12 while CI still has npm 10 baked in the image, or other way around. Different npm versions mean different install behavior. Pin your npm version everywhere.
npxand global installs have their own story. The allowlist inpackage.jsoncovers your project. For npx andnpm install -gyou control script execution through theallow-scriptsconfig. Don’t forget these, npx is a popular attack target exactly because people run it casually.- The allowlist needs maintenance. Every time you add a dependency that runs scripts, somebody has to approve it. That is the point, it is a review step. But make sure your team knows it is now part of adding a dependency, otherwise you get drive-by approvals just to make the error go away. Approving everything blindly puts you back where you started.
What to do now
You don’t need to wait for July. Everything is already available behind warnings in npm 11.16.0:
# upgrade npm
npm install -g npm@latest
# run your normal install and read the warnings
npm install
# see what would be blocked under v12 defaults
npm approve-scripts --allow-scripts-pending
Then approve what you trust, deny the rest, commit package.json, and run your full build and test suite. If everything still works, you are ready for v12 before it even ships. Anything you leave unapproved simply stops running after the upgrade.
If you use git or URL dependencies anywhere in your tree, decide now if you really need them. Most of the time there is a registry version you can use instead. If you must keep them, document the --allow-git or --allow-remote flags in your install scripts so the knowledge does not live in one person’s head.
We review CI/CD and dependency security as part of our security engineering work. We can tell you exactly which packages, scripts and workflows need attention before July.
Book a free callReferences
- GitHub Changelog: Upcoming breaking changes for npm v12
- GitHub Changelog: npm bulk trusted publishing, config and script security
- npm Docs: npm approve-scripts
- npm Docs: npm deny-scripts
- npm Docs: allow-scripts config
- GitHub community discussion on the npm v12 changes
- Hadosec: Inside the AntV Supply Chain Attack