Handle pnpm 10 blocked postinstall scripts
Review a skipped dependency build, allow that package with onlyBuiltDependencies and rebuild it under pnpm 10.
You install a project with pnpm 10. The package is in node_modules, but a tool that depends on its build step cannot find the generated file. Check whether pnpm skipped the dependency's install script before reinstalling the package.
Check what pnpm skipped
pnpm 10 changed the default for dependency lifecycle scripts. A registry dependency can be present on disk while its build or postinstall step remains blocked. The install output can list ignored build scripts. Start with the name in that output and find out what its script does.
To reproduce the warning, create a scratch project and save this as builder/package.json. The postinstall writes built.txt inside the installed package.
{
"name": "report-builder",
"version": "1.0.0",
"scripts": {
"postinstall": "node -e \"require('node:fs').writeFileSync('built.txt', 'ready')\""
}
}Save this as package.json at the project root.
{
"private": true,
"dependencies": {
"report-builder": "file:./report-builder-1.0.0.tgz"
}
}Pack the dependency and run the install from that root with pnpm 10.
npm pack ./builder
pnpm installWith the default policy, the ignored-build warning names report-builder and node_modules/report-builder/built.txt is missing.
Allow one dependency to build
Review the dependency's lifecycle script and the version your lockfile resolves. If the build belongs there, add the package name to onlyBuiltDependencies in the root pnpm-workspace.yaml. Keep any names you already reviewed.
onlyBuiltDependencies:
- report-builderThis grants build permission to report-builder on installs that use the checked-in workspace policy.
If your workspace already uses allowBuilds (available since pnpm 10.26), put report-builder: true under that key.
diagram
One package, two build outcomes
Rebuild that dependency in your working copy after changing the policy.
pnpm rebuild report-builderThe rebuild logs the package's postinstall, and built.txt appears under node_modules/report-builder.
Commit the workspace policy and check a clean install before handing the change to CI. A workspace may contain other packages that share this policy, so grant only the one whose build you reviewed. A name-only entry covers future versions with that name. Review lockfile updates for approved dependencies when their versions change.
If the file is still missing and the postinstall ran, start with its first build error.