Bun "Blocked ... lifecycle scripts" (trustedDependencies) in CI
Bun does not run postinstall/lifecycle scripts for packages that are not in trustedDependencies. In CI a package that needs a postinstall build (esbuild, a native addon) is left unbuilt, so it fails at runtime.
What this error means
bun install reports it blocked scripts for a package, and a later step fails because the package expected its postinstall build to have run.
bun install
Blocked 1 postinstall. Run `bun pm untrusted` for details.
# later:
error: Cannot find module "esbuild-linux-64" (postinstall did not run)Common causes
The package is not in trustedDependencies
Bun blocks lifecycle scripts by default for security, so a package needing a postinstall build is skipped unless trusted.
A native package relies on postinstall to build
The dependency downloads or compiles a binary in postinstall; with the script blocked, the binary is missing at runtime.
How to fix it
Add the package to trustedDependencies
- Run
bun pm untrustedto list packages whose scripts were blocked. - Add the ones you trust to
trustedDependenciesin package.json. - Reinstall so their postinstall scripts run.
{
"trustedDependencies": ["esbuild", "sharp"]
}Run trusted scripts explicitly
After adding a package to trustedDependencies, reinstall so Bun executes the previously blocked scripts.
bun install
bun pm trust esbuildHow to prevent it
- List packages that need postinstall in trustedDependencies.
- Review bun pm untrusted output when a native build is missing.
- Keep trustedDependencies minimal and audited.