How to fix npm ERR! code ELIFECYCLE npm ERR! errno 126 npm ERR! Exit status 126 in npm
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.
Quick fix
Fixes ELIFECYCLE
chmod +x node_modules/.bin/*- Fix execute permissions on node_modules/.bin
- Delete node_modules and reinstall
- Fix permissions for specific script if others work
- Check if running npm as root is the issue
chmod +x node_modules/.bin/*npm ERR! code ELIFECYCLEnpm ERR! errno 126npm ERR! Exit status 126
What this error means
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.
Typical symptoms
- npm start, npm run build, or other npm scripts fail with ELIFECYCLE error
- Error message shows 'Permission denied' for specific binaries like react-scripts, webpack, or cross-env
- Works fine on one system but fails after copying project to another machine
- Problem occurs after moving project from Windows to WSL2 or Linux with node_modules included
- CI/CD pipelines fail at npm script execution steps
Common causes
- node_modules copied from one system to another without running npm install—file permissions don't transfer properly
- node_modules installed by a different user account, causing permission mismatches
- Project transferred from Windows to Linux/macOS where permission bits work differently
- Files in node_modules/.bin/ lack execute (+x) permission for the current user
- npm scripts run as a restricted user without permission to execute binaries
- Filesystem mounted with noexec flag preventing any script execution
How to fix "npm ERR! code ELIFECYCLE npm ERR! errno 126 npm ERR! Exit status 126"
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.
Advanced notes
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.
Frequently asked questions
- What does "ELIFECYCLE" mean?
- 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. bin/ don't have execute permissions.
- How do I fix "ELIFECYCLE"?
- 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.
- What causes "ELIFECYCLE"?
- node_modules copied from one system to another without running npm install—file permissions don't transfer properly node_modules installed by a different user account, causing permission mismatches Project transferred from Windows to Linux/macOS where permission bits work differently
- Is the "ELIFECYCLE" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 💬MagicMirror Forum: ELIFECYCLE error(Stack Overflow)
- 💬SO: ELIFECYCLE 126 error(Stack Overflow)
- 💬SuperUser: Exit code 126(Stack Overflow)