How to fix npm ERR! code ELIFECYCLE npm ERR! errno 126 npm ERR! Exit status 126 in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025· 168 views

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/*
  1. Fix execute permissions on node_modules/.bin
  2. Delete node_modules and reinstall
  3. Fix permissions for specific script if others work
  4. Check if running npm as root is the issue
npm — error
chmod +x node_modules/.bin/*
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm 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

  1. node_modules copied from one system to another without running npm install—file permissions don't transfer properly
  2. node_modules installed by a different user account, causing permission mismatches
  3. Project transferred from Windows to Linux/macOS where permission bits work differently
  4. Files in node_modules/.bin/ lack execute (+x) permission for the current user
  5. npm scripts run as a restricted user without permission to execute binaries
  6. 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"

1Fix execute permissions on node_modules/.bin

Add execute permissions to the .bin directory where npm stores script binaries. This is the most common and fastest fix:

bash
chmod +x node_modules/.bin/*

Or to be more conservative and only give permissions to the current user:

bash
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.

2Delete node_modules and reinstall

If chmod doesn't work, completely remove node_modules and reinstall. This ensures all files are created fresh with correct permissions:

bash
rm -rf node_modules
rm package-lock.json
npm install

On Windows, if rm is not available, use PowerShell:

powershell
Remove-Item -Recurse -Force node_modules
Remove-Item package-lock.json
npm install

This is the most reliable solution when node_modules was copied from another system.

3Fix permissions for specific script if others work

If only one npm script is failing (e.g., react-scripts), fix just that binary:

bash
chmod +x node_modules/.bin/react-scripts

Replace react-scripts with whatever binary is failing. You can find the exact name in the error message or by listing the directory:

bash
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).

4Check if running npm as root is the issue

Running npm or Node as root (via sudo) can cause permission problems. Verify you're not using sudo:

bash
# Don't do this:
sudo npm install
sudo npm start

# Do this instead:
npm install
npm start

If you previously ran npm with sudo, reinstall dependencies as your normal user:

bash
sudo rm -rf node_modules
sudo rm package-lock.json
npm install

Non-root user execution prevents permission complications.

5For WSL2/Git Bash: Use proper line endings

If moving from Windows to WSL2, verify scripts use Unix line endings (LF not CRLF):

bash
chmod +x node_modules/.bin/*

Then in your git config for WSL:

bash
git config core.autocrlf false

After fixing git config, reinstall:

bash
rm -rf node_modules
npm install

CRLF 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