Skip to content
Latchkey

npm Script "command not found" (PATH) in CI - Fix Missing Binaries

npm scripts run with node_modules/.bin on PATH. A command-not-found inside a script means the binary was never installed or is not a local devDependency.

What this error means

An npm script fails with sh: <tool>: command not found (often exit 127). The tool runs locally because it is installed globally there, but CI has only what package.json declares.

npm
> my-app@1.0.0 build
> vite build

sh: 1: vite: command not found
npm ERR! code 127

Common causes

The tool is not a devDependency

The script relies on a globally installed binary that exists locally but not in CI.

node_modules/.bin is not on PATH

Calling the tool outside an npm script, or in a subshell that drops PATH, misses the local bin directory.

How to fix it

Add the tool as a devDependency

  1. Install the binary as a devDependency and commit the lockfile.
  2. Call it from an npm script so .bin is on PATH.
Terminal
npm install -D vite

Invoke via npx or a script

  1. Use npx <tool> to resolve a local binary.
  2. Keep tool invocations inside npm scripts.
Terminal
npx vite build

How to prevent it

  • Declare every tool a script uses as a devDependency, call them through npm scripts or npx, and never rely on globally installed binaries that only exist on a developer machine.

Related guides

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