Skip to content
Latchkey

Prettier exit code 1 fails the workflow step in CI

Prettier exits 1 when --check or --list-different finds files that are not formatted. A different exit code (2) means Prettier itself errored, such as a parse failure or bad config.

What this error means

A Prettier step fails the workflow with "Process completed with exit code 1." after listing unformatted files, or your wrapper reports "Command failed with exit code 1".

Prettier
$ prettier --list-different .
src/index.ts
src/server.ts
Error: Process completed with exit code 1.

Common causes

Unformatted files (exit 1, the normal gate)

--check and --list-different exit 1 when at least one file differs from Prettier's output. This is the formatting gate doing its job.

A real Prettier error would exit 2, not 1

If the failure is a syntax or config error rather than formatting, Prettier exits 2; do not confuse the two when triaging.

How to fix it

Format and re-check

  1. Run prettier --write . to format the listed files.
  2. Commit the changes.
  3. Re-run the check command and confirm exit 0.
Terminal
npx prettier --write .

Triage an exit code 2 separately

If Prettier exits 2, read the parse or config error it prints; formatting is not the cause and --write will not help.

How to prevent it

  • Use --check in CI and --write locally on the same version.
  • Keep the formatting clean with a pre-commit hook.
  • Treat exit 2 as a code or config bug, not a formatting miss.

Related guides

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