Skip to content
Latchkey

pnpm ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL in CI

A pnpm -r (recursive) command ran a script across packages and one of them exited non-zero. pnpm reports the recursive failure; the real error is in that package log.

What this error means

pnpm -r build or test ends with "ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL" naming the package whose script failed, with that package output above.

pnpm
/workspace/packages/api build:
ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @acme/api@1.0.0 build:
`tsc -b` failed with exit code 2

Common causes

A package script failed

One package build or test exited non-zero; the recursive run surfaces it as the first failure.

Build order or missing dep

A package compiled before its dependency, or a missing dependency caused the script to fail.

Environment difference in CI

A script depends on a tool or env present locally but not on the runner.

How to fix it

Read the failing package log

  1. Open the output of the named package and fix the real error.

Run that package in isolation

  1. Filter to the failing package to iterate faster.
Terminal
pnpm --filter @acme/api build

How to prevent it

  • Build in topological order and keep package scripts environment-independent so a recursive run does not fail on the runner.

Related guides

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