You upgraded to pnpm 11 and an install that passed yesterday now fails:
[ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: [email protected], [email protected]
Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.pnpm 12 reports the same error with a different layout:
Error: ERR_PNPM_IGNORED_BUILDS
× installing dependencies
╰─▶ Ignored build scripts: [email protected], [email protected]
help: Run "pnpm approve-builds" to pick which dependencies should be allowed
to run scripts.The fix takes one command and one committed file. This guide shows how to decide which packages to allow, how to make CI pass, how to move old pnpm 10 settings across, and one trap when you change your mind later.
Why pnpm 11 fails here
Some packages run a script when they are installed, usually postinstall. Most of these scripts are harmless: they download a binary, compile a native addon or print a message. But install scripts are also the main way compromised packages run code on your machine. The pnpm supply-chain security page puts it plainly: historically, most compromised packages used postinstall scripts.
pnpm 10 already skipped these scripts unless you allowed them, but it only printed a warning and exited with code 0:
╭ Warning ─────────────────────────────────────────────────────────────────────╮
│ │
│ Ignored build scripts: [email protected], [email protected]. │
│ Run "pnpm approve-builds" to pick which dependencies should be allowed │
│ to run scripts. │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
Done in 7.6s using pnpm v10.34.9pnpm 11 made strictDepBuilds default to true. Any dependency with a build script that nobody has reviewed now makes the install exit with a non-zero code. pnpm 12 keeps that default.
Two details matter:
- The packages are still installed.
node_modulesis populated, and only the scripts are skipped. Locally that is easy to miss. In CI the non-zero exit code fails the job. - "Reviewed" means listed. A package passes only if it appears in
allowBuilds, either astrue(run its scripts) orfalse(never run them). In pnpm 10, anything not on the allow list was skipped with a warning. In pnpm 11 it fails the install until you decide.
1. Decide what each package needs
Look at what the script does before you allow it. Each package lists its scripts in node_modules/<name>/package.json:
jq .scripts node_modules/core-js/package.json{
"postinstall": "node -e \"try{require('./postinstall')}catch(e){}\""
}A simple rule:
- Allow packages whose script fetches or builds something the package cannot work without. Puppeteer downloads Chrome in
postinstall, for example. Packages that compile a native addon withnode-gypare another case. - Deny packages whose script only prints a message or sends telemetry. The
core-jsscript prints a funding message, so denying it changes nothing.
Some cases are in between. The esbuild script checks that the right platform binary is installed, downloads it if the optional dependency is missing, and on macOS and Linux swaps the JavaScript wrapper for the native binary so it starts faster. With the build skipped, esbuild --version still works, because the binary comes in through the platform-specific optional dependency. Allowing it is the safer default.
Fewer packages need builds than a few years ago. sharp 0.35.5 and better-sqlite3 13.0.3 are not flagged at all, because both now ship prebuilt binaries instead of running an install script.
2. Record the decision with pnpm approve-builds
Pass package names to allow them, and prefix a name with ! to deny it. Use single quotes so your shell does not treat ! as history expansion:
pnpm approve-builds esbuild '!core-js'.../[email protected]/node_modules/esbuild postinstall$ node install.js
.../[email protected]/node_modules/esbuild postinstall: DoneApproved packages that were waiting are built straight away. The decisions are written to pnpm-workspace.yaml, which pnpm creates if it does not exist:
allowBuilds:
core-js: false
esbuild: trueRun without arguments, pnpm approve-builds opens an interactive picker instead. You can also edit allowBuilds by hand. It accepts version ranges such as [email protected] || 21.6.5: true, which are covered in the allowBuilds reference.
When you add a new dependency, you can approve it in the same command:
pnpm add esbuild --allow-build=esbuildThis writes esbuild: true to allowBuilds as part of the install.
3. Commit the file so CI passes
allowBuilds lives in pnpm-workspace.yaml, so CI only sees it if the file is committed. A clean frozen-lockfile install without it, with pnpm 12:
CI=true pnpm install --frozen-lockfiledependencies:
+ core-js 3.51.0
+ esbuild 0.28.2
+ sharp 0.35.5
Error: ERR_PNPM_IGNORED_BUILDS
× installing dependencies
╰─▶ Ignored build scripts: [email protected], [email protected]
help: Run "pnpm approve-builds" to pick which dependencies should be allowed
to run scripts.The same command with the pnpm-workspace.yaml from step 2 next to the lockfile:
dependencies:
+ core-js 3.51.0
+ esbuild 0.28.2
+ sharp 0.35.5
Done in 706ms using pnpm v12.18.0Treat new entries in this file like any other code change. A pull request that adds some-package: true is asking to run that package's install script on every developer machine and CI runner.
Upgrading from pnpm 10 settings
If you already had an allow list in pnpm 10, you may still see the error, because pnpm 11 no longer reads the pnpm field in package.json. With this old setting:
{
"pnpm": {
"onlyBuiltDependencies": ["esbuild"]
}
}pnpm install warns and then fails:
[WARN] The "pnpm" field in package.json is no longer read by pnpm. The following keys were ignored: "pnpm.onlyBuiltDependencies". See https://pnpm.io/settings for the new home of each setting.[ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: [email protected], [email protected]onlyBuiltDependencies, neverBuiltDependencies, ignoredBuiltDependencies, onlyBuiltDependenciesFile and ignoreDepScripts were all removed in pnpm 11. The official codemod moves them into allowBuilds:
pnpm dlx codemod run pnpm-v10-to-v11It removed the pnpm field from package.json and wrote:
allowBuilds:
esbuild: trueThe next install still failed, this time on core-js alone. pnpm 10 skipped core-js because it was not on the allow list. pnpm 11 wants an explicit answer, so deny it:
pnpm approve-builds '!core-js'After that, pnpm install passes. The codemod also moves your other settings from the pnpm field and from .npmrc into pnpm-workspace.yaml. Review its full diff before you commit.
Changing a deny to an allow
If you denied a package and later need its script, approving it again updates the file but does not run the script:
pnpm approve-builds puppeteer[WARN] The following packages are not awaiting approval: puppeteerallowBuilds now says puppeteer: true, but Chrome was never downloaded, so the first launch fails:
Error: Could not find Chrome (ver. 157.0.8103.50). This can occur if either
1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) orA denied package is not "awaiting approval", so pnpm saves the decision without building it. Run the script yourself:
pnpm rebuild puppeteer.../node_modules/puppeteer postinstall$ node install.mjs
.../node_modules/puppeteer postinstall: chrome (157.0.8103.50) downloaded to …/puppeteer/chrome/mac_arm-157.0.8103.50
.../node_modules/puppeteer postinstall: DoneThe same script now prints Chrome/157.0.8103.50. Puppeteer's installation guide describes this error, and you can download the browser by hand instead of allowing the script.
Switches that hide the error
Two settings make the error go away without a decision per package. Both have a cost.
strictDepBuilds: false brings back the pnpm 10 behaviour: unreviewed scripts are skipped and you get a warning instead of a failure.
strictDepBuilds: falseIgnored build scripts: [email protected], [email protected].
Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.
Done in 2.1s using pnpm v12.18.0The trap is the same as in pnpm 10. When a new dependency really needs its build, the install still passes and the package breaks later at runtime.
dangerouslyAllowAllBuilds: true goes the other way and runs every install script, except those set to false in allowBuilds. That includes transitive dependencies and any scripts added in future versions. It turns off the protection completely, and the pnpm docs recommend against it.
Next steps
- Read the pnpm 10 to 11 migration guide for the other defaults that changed, such as
minimumReleaseAge, which delays newly published versions by a day. - See the
approve-buildsreference for the--alland--globaloptions. - If you use pnpm 12.11 or later, look at the newer
permissionssetting in the build settings reference, which can hold the same decisions.