CI "prettier: command not found" - Fix Missing Prettier Binary
By Daniel Zoghalchali·Latchkey
The shell could not find a prettier executable. Prettier is not installed in the project, dev dependencies were pruned, or the step invoked a bare prettier that only resolves to a global install CI does not have.
What this error means
The format step fails with prettier: command not found and exit code 127. The same command works locally where Prettier is on PATH or installed.
shell
$prettier --check .
/bin/sh: 1: prettier: command not found
Error: Process completed with exit code 127.
Diagnose it: config resolution and version drift
Lint failures that appear only in CI are almost always a different linter version or a different resolved configuration, not new violations in the code.
Do not pass --omit=dev/--production to the install before formatting.
Define a "format:check": "prettier --check ." npm script.
Use npm ci (with dev deps) so the binary is present.
How to prevent it
Declare Prettier in devDependencies and run it via an npm script or npx.
Keep dev dependencies installed for the format step in CI.
Never rely on a global Prettier install in CI.
Frequently asked questions
What causes CI "prettier: command not found"?
There are 2 common causes: prettier not installed or dev deps pruned and calling a bare global prettier. Prettier is missing from devDependencies, or the install ran with --omit=dev/--production, so the binary is absent in CI.
How do I fix CI "prettier: command not found"?
There are 2 fixes depending on which cause you have: install prettier and call it locally and keep dev dependencies for the format step. Work through them in order, since the first is the most common.
What does CI "prettier: command not found" actually mean?
The format step fails with prettier: command not found and exit code 127.
How do I stop CI "prettier: command not found" happening again?
Declare Prettier in devDependencies and run it via an npm script or npx. The prevention section lists 3 changes that keep it from recurring.