Skip to content
Latchkey

pnpm "ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL" in CI

When pnpm -r run <script> executes a script across every workspace package, a non-zero exit in any one package aborts the recursive run and reports it with this code. The real failure is the script output above.

What this error means

A pnpm -r build or pnpm -r test step fails with "ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @acme/web@1.0.0 build: Failed" after one package's script exited non-zero.

pnpm
@acme/web:build: error TS2322: Type 'string' is not assignable to type 'number'.
ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @acme/web@1.0.0 build: Failed

Common causes

A script genuinely failed in one package

The recursive run surfaces the first package whose script exited non-zero; the underlying error (a type error, a failing test) is in the log just above.

Packages built in the wrong order

A package that depends on another was built before its dependency, so it could not find generated output and its script failed.

How to fix it

Fix the failing package's script

  1. Scroll up to the package name in the error and read its script output.
  2. Reproduce locally with pnpm --filter <pkg> run <script>.
  3. Fix the underlying error, then re-run the recursive command.
Terminal
pnpm --filter @acme/web run build

Build in topological order

Use pnpm's dependency-aware ordering so each package builds after the packages it depends on.

Terminal
pnpm -r --workspace-concurrency=1 run build

How to prevent it

  • Reproduce package failures with --filter before running the full recursive command.
  • Rely on pnpm topological ordering so dependencies build first.
  • Keep per-package scripts self-contained so failures are local and clear.

Frequently asked questions

What causes ""recursive run failed""?
The recursive run surfaces the first package whose script exited non-zero; the underlying error (a type error, a failing test) is in the log just above.
How do I fix "recursive run failed"?
Fix the failing package's script

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card