Skip to content
Latchkey

Turborepo "command finished with error" in CI

Turborepo ran a task that exited non-zero and reported "command finished with error". The real failure is in the underlying package script that turbo orchestrated.

What this error means

turbo run build (or test) ends with "command (package#build) exited (1)" and "command finished with error". The summary masks which package and which script actually failed.

node
web#build: command (/work/repo/apps/web) /bin/sh -c next build exited (1)

 ERROR  run failed: command  exited (1)
Tasks:    3 successful, 4 total
 command finished with error: command (apps/web) exited (1)

Common causes

A package script failed

The wrapped command (next build, tsc, etc.) exited non-zero; turbo only relays the failure.

A missing dependency in the task graph

A task ran before its prerequisite output existed because the dependsOn wiring is incomplete.

How to fix it

Read the failing package log

Identify the package#task that exited 1 and run that script directly to see the real error.

Terminal
turbo run build --filter=web -- --verbosity=2
# or run the underlying script directly
npm run build -w apps/web

Fix the pipeline dependencies

Ensure each task declares the upstream outputs it needs via dependsOn.

turbo.json
// turbo.json
{ "tasks": { "build": { "dependsOn": ["^build"], "outputs": ["dist/**"] } } }

How to prevent it

  • Run the failing package script directly to surface the root cause.
  • Wire dependsOn so upstream outputs exist before dependents run.
  • Keep task outputs declared so cache and ordering stay correct.

Related guides

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