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 notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm