npm Script Exit 127 "command not found" - Fix Missing Tool in CI
Exit code 127 from a shell means "command not found". When an npm script calls a tool that is not installed, not a local dependency, or not on PATH, the script aborts with 127.
What this error means
An npm run <script> step fails with sh: 1: <tool>: not found and exit code 127. It typically works locally (where the tool is globally installed) but fails in CI, where only declared dependencies are present.
> app@1.0.0 build
> some-cli --out dist
sh: 1: some-cli: not found
npm error code 127
npm error command failedCommon causes
The tool is not a project dependency
The script relies on a globally-installed binary present on your machine but absent in CI. A clean install only provides declared dependencies, so the command is missing.
The binary is not on PATH
A locally-installed dependency’s binary lives in node_modules/.bin. npm scripts add that to PATH, but a directly-invoked subshell or wrong working directory can miss it.
How to fix it
Add the tool as a dependency
Declare the binary so a clean install provides it, and npm puts it on the script PATH.
npm install --save-dev some-cli
# now "some-cli" resolves via node_modules/.bin inside npm scriptsInvoke local binaries correctly
- Call the tool from an npm script (not a bare subshell) so .bin is on PATH.
- Or use
npx some-clito resolve the local/temporary binary explicitly. - Confirm the script runs from the package root where node_modules exists.
How to prevent it
- Declare every tool a script uses as a dependency.
- Run tools through npm scripts or npx, not globals.
- Keep the working directory at the package root.