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.
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.
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 [email protected]
# For GitLab
ssh -T [email protected]
# For Bitbucket
ssh -T [email protected]You 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 [email protected]: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/[email protected]
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"
}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 gitnpm 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