Exit code 126 means npm found a command but cannot execute it due to missing permissions. This usually happens when node_modules binaries lack execute permissions, often after copying projects between systems.
Exit code 126 is a Linux/Unix permission error that specifically means the command was found but is not executable. Unlike exit code 127 (command not found), the issue is not that npm can't locate the script or binary—it's that npm lacks permission to run it. This error occurs when npm tries to execute a script from your package.json (like 'start', 'build', or 'test') but the binaries in node_modules/.bin/ don't have execute permissions. This commonly happens when node_modules is copied from one system to another (Windows to Linux/macOS, or between different user accounts) instead of being generated fresh via npm install.
Add execute permissions to the .bin directory where npm stores script binaries. This is the most common and fastest fix:
chmod +x node_modules/.bin/*Or to be more conservative and only give permissions to the current user:
chmod u+x node_modules/.bin/*This adds execute permission (+x) to all files in the .bin directory, which should immediately resolve the permission denied error.
If chmod doesn't work, completely remove node_modules and reinstall. This ensures all files are created fresh with correct permissions:
rm -rf node_modules
rm package-lock.json
npm installOn Windows, if rm is not available, use PowerShell:
Remove-Item -Recurse -Force node_modules
Remove-Item package-lock.json
npm installThis is the most reliable solution when node_modules was copied from another system.
If only one npm script is failing (e.g., react-scripts), fix just that binary:
chmod +x node_modules/.bin/react-scriptsReplace react-scripts with whatever binary is failing. You can find the exact name in the error message or by listing the directory:
ls -la node_modules/.bin/Look for files without an 'x' in the permission string (e.g., -rw-r--r-- instead of -rwxr-xr-x).
Running npm or Node as root (via sudo) can cause permission problems. Verify you're not using sudo:
# Don't do this:
sudo npm install
sudo npm start
# Do this instead:
npm install
npm startIf you previously ran npm with sudo, reinstall dependencies as your normal user:
sudo rm -rf node_modules
sudo rm package-lock.json
npm installNon-root user execution prevents permission complications.
If moving from Windows to WSL2, verify scripts use Unix line endings (LF not CRLF):
chmod +x node_modules/.bin/*Then in your git config for WSL:
git config core.autocrlf falseAfter fixing git config, reinstall:
rm -rf node_modules
npm installCRLF line endings on WSL can prevent execution even with correct permissions.
Exit code 126 is distinct from exit code 127 (command not found). With 126, the file exists but isn't executable—this is always a permissions issue. If you're running npm in Docker or CI/CD, ensure the Dockerfile or build script runs npm install in the target environment rather than copying node_modules from the host. On servers with strict security policies, node_modules might be on a filesystem mounted with the 'noexec' flag, which prevents any script execution regardless of permissions—in that case, request your system administrator to remount the partition without noexec. For maximum security in production, avoid using 'chmod a+x' (all users) and instead use 'chmod u+x' (owner only) or 'chmod 755' if you need group execution.
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