yarn "error Command failed with exit code 1" - Diagnose the Real Failure in CI
"Command failed with exit code 1" is yarn reporting that a script it ran exited non-zero. Like npm’s ELIFECYCLE, it is a wrapper - the real failure is in the lines above it.
What this error means
A yarn <script> step ends with error Command failed with exit code 1. The actual error - a failed test, a compiler error, a missing file - is printed just before the yarn summary, not in it.
yarn output
$ tsc -p tsconfig.json
src/index.ts:12:7 - error TS2322: Type 'string' is not assignable to type 'number'.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation.Common causes
The underlying command failed
The exit-code-1 message just reflects that the command your script ran returned non-zero - a failed build, test, or lint. yarn is the messenger.
How to fix it
Read above the yarn summary
- Scroll up from
error Command failed with exit code 1to the real error. - Reproduce the underlying command directly (e.g. run
tsc -p tsconfig.json) to iterate faster. - Fix that error; the yarn wrapper message goes away with it.
How to prevent it
- Treat the message as "my script failed", not a yarn bug.
- Surface the real command’s output clearly in CI logs.
Related guides
yarn "Couldn't find any versions for <pkg> that match <range>" - Fix in CIFix yarn "Couldn't find any versions for <pkg> that matches <range>" in CI - a version range no published rel…
Node "FATAL ERROR: … Allocation failed" in CI - Tune V8 Memory for the RunnerFix Node "FATAL ERROR: … Allocation failed" specifically in CI - tune V8 heap and semi-space for a constraine…