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 127Common 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
- Install the binary as a devDependency and commit the lockfile.
- Call it from an npm script so .bin is on PATH.
Terminal
npm install -D viteInvoke via npx or a script
- Use npx <tool> to resolve a local binary.
- Keep tool invocations inside npm scripts.
Terminal
npx vite buildHow 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
npm Script Exit 127 "command not found" - Fix Missing Tool in CIFix npm scripts failing with exit code 127 "command not found" in CI - a binary the script calls is not insta…
npm run "spawn ENOENT" / "sh: command not found" - Fix Script Shell in CIFix npm scripts failing with "spawn ENOENT" or "sh: <cmd>: not found" in CI - a command in the script is not…
npm "missing script: build" in CI - Fix Undefined npm ScriptsFix "npm ERR! missing script: build" in CI when the named script is not defined in package.json scripts, or t…