Skip to content
Latchkey

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.

Terminal
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

  1. Run bun pm untrusted to list packages whose scripts were blocked.
  2. Add the ones you trust to trustedDependencies in package.json.
  3. Reinstall so their postinstall scripts run.
package.json
{
  "trustedDependencies": ["esbuild", "sharp"]
}

Run trusted scripts explicitly

After adding a package to trustedDependencies, reinstall so Bun executes the previously blocked scripts.

Terminal
bun install
bun pm trust esbuild

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →