Exit code 127 means "command not found." This occurs when npm tries to run a script that references a command that doesn't exist or isn't in your PATH.
Exit code 127 in Unix/Linux systems specifically means "command not found." When an npm script tries to execute a program that doesn't exist or isn't accessible, the shell returns this code. This is different from exit code 1 (general error) or 126 (permission denied). Code 127 specifically indicates the command binary couldn't be located.
Check what command failed:
# See script content
cat package.json | jq '.scripts.build'
# If script is "webpack", check if installed
which webpack
ls node_modules/.bin/webpackAdd the package:
# Install locally (usually correct)
npm install webpack --save-dev
# Or globally if needed
npm install -g webpackCheck bin directory exists:
ls node_modules/.bin
# npm should automatically add this to PATH
# Verify with verbose output
npm run build --verboseHandle OS differences:
{
"scripts": {
"build": "webpack",
"clean": "rimraf dist"
}
}Use cross-platform packages like rimraf, cross-env, shx.
Run without installing globally:
npx webpack
npx jestnpx finds and runs the local or downloads temporarily.
Clean install:
rm -rf node_modules
npm install
npm run buildnpm automatically prepends node_modules/.bin to PATH when running scripts. If a command works via npx but not npm run, the PATH setup may be failing. On Windows, bin commands are .cmd files. Cross-platform scripts should use npm packages (rimraf instead of rm, cross-env for env vars) rather than shell commands.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error