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

npmINTERMEDIATEMEDIUMUpdated Dec 6, 2025· 227 views

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
  1. Start SSH agent and add key
  2. Test SSH connection to Git host
  3. Use HTTPS instead of Git protocol
  4. Clean install dependencies
npm — error
# 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
npm ERR! code ELIFECYCLE
npm ERR! errno 128
npm 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

  1. SSH key not loaded into SSH agent
  2. SSH agent not running
  3. SSH key lacks access to private repository
  4. Git URL protocol blocked by firewall (git:// on port 9418)
  5. package-lock.json references unavailable git commits
  6. Incorrect authentication token for HTTPS Git URLs
  7. Too many concurrent SSH connections in large monorepos

How to fix "npm ERR! code ELIFECYCLE npm ERR! errno 128 npm ERR! Exit status 128"

1Start SSH agent and add key

The most common fix—ensure SSH agent is running with your key:

bash
# 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
2Test SSH connection to Git host

Verify SSH access to your Git provider:

bash
# For GitHub
ssh -T git@github.com

# For GitLab
ssh -T git@gitlab.com

# For Bitbucket
ssh -T git@bitbucket.org

You should see a success message with your username.

3Use HTTPS instead of Git protocol

If port 22 is blocked, switch to HTTPS:

bash
# 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:
4Clean install dependencies

Reset npm state and reinstall:

bash
# Clear npm cache
npm cache clean --force

# Remove lock file and modules
rm -rf node_modules package-lock.json

# Reinstall
npm install
5Configure SSH for Docker/CI

In CI/CD environments, SSH keys need explicit setup:

GitHub Actions:

yaml
- uses: webfactory/ssh-agent@v0.5.4
  with:
    ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

Docker:

dockerfile
# 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 install
6Use deploy tokens for CI

For private repos in CI, use HTTPS with tokens instead of SSH:

bash
# 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:

bash
npm install --maxsockets=2

On 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:

bash
# ~/.ssh/config
Host github.com
  Hostname ssh.github.com
  Port 443
  User git

Frequently 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