How to fix npm ERR! code ELIFECYCLE npm ERR! errno 128 npm ERR! Exit status 128 in npm
Exit code 128 in npm typically indicates a Git-related failure, usually SSH authentication issues when installing dependencies from Git repositories. Check SSH key configuration and Git access.
Quick fix
Fixes npm ERR! code ELIFECYCLE npm ERR! errno 128 npm ERR! Exit status 128
# Start SSH agent
eval "$(ssh-agent -s)"
# Add your SSH key
ssh-add ~/.ssh/id_rsa
# Or for newer ed25519 keys
ssh-add ~/.ssh/id_ed25519
# Verify key is loaded
ssh-add -l- Start SSH agent and add key
- Test SSH connection to Git host
- Use HTTPS instead of Git protocol
- Clean install dependencies
# Start SSH agenteval "$(ssh-agent -s)"# Add your SSH keyssh-add ~/.ssh/id_rsa# Or for newer ed25519 keysssh-add ~/.ssh/id_ed25519# Verify key is loadedssh-add -lnpm ERR! code ELIFECYCLEnpm ERR! errno 128npm ERR! Exit status 128
What this error means
Exit code 128 is a Git-specific error code indicating that a Git operation failed during npm install. This commonly occurs when package.json includes dependencies hosted on Git repositories (using `git+ssh://` or `git+https://` URLs) and authentication fails. The most frequent cause is SSH key issues—either the SSH key isn't loaded, the SSH agent isn't running, or the key doesn't have access to the private repository. This error is especially common in CI/CD environments where SSH keys need explicit configuration.
Typical symptoms
- npm install fails on git+ssh:// or git+https:// dependencies
- Error message includes "Could not read from remote repository"
- Works on local machine but fails in CI/Docker
- Works for some team members but not others
- Intermittent failures with many git dependencies
- "Permission denied (publickey)" appears before ELIFECYCLE
Common causes
- SSH key not loaded into SSH agent
- SSH agent not running
- SSH key lacks access to private repository
- Git URL protocol blocked by firewall (git:// on port 9418)
- package-lock.json references unavailable git commits
- Incorrect authentication token for HTTPS Git URLs
- Too many concurrent SSH connections in large monorepos
How to fix "npm ERR! code ELIFECYCLE npm ERR! errno 128 npm ERR! Exit status 128"
The most common fix—ensure SSH agent is running with your key:
# Start SSH agent
eval "$(ssh-agent -s)"
# Add your SSH key
ssh-add ~/.ssh/id_rsa
# Or for newer ed25519 keys
ssh-add ~/.ssh/id_ed25519
# Verify key is loaded
ssh-add -lVerify SSH access to your Git provider:
# For GitHub
ssh -T git@github.com
# For GitLab
ssh -T git@gitlab.com
# For Bitbucket
ssh -T git@bitbucket.orgYou should see a success message with your username.
If port 22 is blocked, switch to HTTPS:
# Configure Git to use HTTPS globally
git config --global url."https://".insteadOf git://
# For GitHub specifically
git config --global url."https://github.com/".insteadOf git@github.com:Reset npm state and reinstall:
# Clear npm cache
npm cache clean --force
# Remove lock file and modules
rm -rf node_modules package-lock.json
# Reinstall
npm installIn CI/CD environments, SSH keys need explicit setup:
GitHub Actions:
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}Docker:
# Mount SSH socket
docker run -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent ...
# Or use BuildKit secrets
RUN --mount=type=ssh npm installFor private repos in CI, use HTTPS with tokens instead of SSH:
# Configure Git to use token
git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
# Or update package.json to use HTTPS
"dependencies": {
"private-pkg": "https://${GITHUB_TOKEN}@github.com/org/repo.git"
}Advanced notes
For large monorepos with many Git dependencies, npm may open too many concurrent SSH connections, causing failures. Reduce concurrency:
npm install --maxsockets=2On Windows with WSL, ensure you're using Linux SSH keys (generated within WSL) or properly mounting Windows SSH keys. The Windows and WSL file systems have different SSH key handling.
For corporate firewalls blocking port 22, configure SSH to use port 443:
# ~/.ssh/config
Host github.com
Hostname ssh.github.com
Port 443
User gitFrequently asked questions
- What does "npm ERR! code ELIFECYCLE npm ERR! errno 128 npm ERR! Exit status 128" mean?
- Exit code 128 is a Git-specific error code indicating that a Git operation failed during npm install. json includes dependencies hosted on Git repositories (using git+ssh:// or git+https:// URLs) and authentication fails. The most frequent cause is SSH key issues—either the SSH key isn't loaded, the SSH agent isn't running, or the key doesn't have access to the private repository.
- How do I fix "npm ERR! code ELIFECYCLE npm ERR! errno 128 npm ERR! Exit status 128"?
- Exit code 128 in npm typically indicates a Git-related failure, usually SSH authentication issues when installing dependencies from Git repositories. Check SSH key configuration and Git access.
- What causes "npm ERR! code ELIFECYCLE npm ERR! errno 128 npm ERR! Exit status 128"?
- SSH key not loaded into SSH agent SSH agent not running SSH key lacks access to private repository
- Is the "npm ERR! code ELIFECYCLE npm ERR! errno 128 npm ERR! Exit status 128" 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
- 💬Stack Overflow: npm install error code 128(Stack Overflow)
- 🐙GitHub #16980: npm/npm(GitHub)
- 💬Stack Overflow: how to solve npm error npm err code elifecycle(Stack Overflow)