Skip to content
Latchkey

CI "prettier: command not found" - Fix Missing Prettier Binary

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.

Terminal
npx eslint --version
npx eslint --print-config path/to/file.ts | head -40
npx eslint --debug path/to/file.ts 2>&1 | grep -i "config" | head

Common causes

Prettier not installed or dev deps pruned

Prettier is missing from devDependencies, or the install ran with --omit=dev/--production, so the binary is absent in CI.

Calling a bare global prettier

The step runs prettier directly, relying on a global install. CI has no global Prettier, so it must use the local binary via npx/an npm script.

How to fix it

Install Prettier and call it locally

Add Prettier as a dev dependency and invoke the project-local binary.

Terminal
npm install -D prettier
npx prettier --check .   # or: npm run format:check

Keep dev dependencies for the format step

  1. Do not pass --omit=dev/--production to the install before formatting.
  2. Define a "format:check": "prettier --check ." npm script.
  3. 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.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card