npm 12, maintained by GitHub, introduces significant security changes by defaulting `allowScripts` to off. This means `preinstall`, `install`, and `postinstall` scripts within dependencies will no longer run automatically. This also applies to implicit `node-gyp` builds for packages containing a `binding.gyp` file and `prepare` scripts from git, file, and link dependencies.
Developers are now required to review pending scripts, approve trusted ones, and commit the resulting allowlist in their `package.json` file. This shift from automatic execution to explicit opt-in aims to reduce the risk of malicious code execution during package installation. These changes were announced in June and were available behind warnings in npm 11.16.0 to allow preparation time.
In addition to script changes, npm 12 also modifies defaults for non-registry sources. The `--allow-git` flag now defaults to `none`, closing a code execution path where a Git dependency's `.npmrc` could override the Git executable. Similarly, `--allow-remote` defaults to `none`, blocking `https` tarball dependencies. The `--allow-file` and `--allow-directory` flags remain unchanged.
GitHub's migration discussion suggests allowing existing scripts first, then tightening controls. Recipes for common tools like Cypress, Playwright, Puppeteer, Electron, and Husky are provided. Global installs and `npx` require configuration via `npm config set allow-scripts=canvas,sharp --location=user`. It has been noted that `ignore-scripts=true` takes precedence over the allowlist, and new package installations can create issues with `npm approve-scripts` if the package is not yet installed.
Alongside these security enhancements, npm 12 also deprecates granular access tokens that bypass two-factor authentication. This further strengthens the security posture of the npm ecosystem.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
npm 12 has been released, making several security-related changes to `npm install` defaults, including disabling automatic execution of install scripts. These changes require developers to explicitly opt-in to script execution, aiming to mitigate supply chain attacks and improve package security.