This error occurs when npm tries to clone a Git dependency using SSH but your SSH key isn't configured or recognized. Common in CI/CD environments, new machines, or when using the wrong SSH key.
When your package.json contains a Git dependency using SSH syntax (like `[email protected]:user/repo.git`), npm needs SSH authentication to clone the repository. This error means SSH authentication failed—typically because no SSH key is available or the key isn't authorized for the repository. This is one of the most common issues when: - Setting up a new development machine - Running npm install in CI/CD pipelines - Working with private repositories - The SSH agent isn't running or doesn't have your key loaded
First, verify you have SSH keys:
ls -la ~/.ssh/
# Look for id_rsa/id_rsa.pub or id_ed25519/id_ed25519.pubIf no keys exist, generate one:
ssh-keygen -t ed25519 -C "[email protected]"Start the SSH agent and add your key:
# Start ssh-agent
eval "$(ssh-agent -s)"
# Add your key
ssh-add ~/.ssh/id_ed25519
# Or for RSA keys:
ssh-add ~/.ssh/id_rsa
# Verify key is loaded
ssh-add -lCopy your public key and add it to your Git hosting service:
# Copy public key to clipboard (macOS)
cat ~/.ssh/id_ed25519.pub | pbcopy
# Or display it to copy manually
cat ~/.ssh/id_ed25519.pubThen:
1. Go to GitHub → Settings → SSH and GPG keys
2. Click "New SSH key"
3. Paste your public key and save
Verify SSH authentication works:
ssh -T [email protected]
# Expected output:
# Hi username! You've successfully authenticated...If this fails, the key isn't properly configured.
If you can't configure SSH, switch to HTTPS:
# Configure git to use HTTPS instead of SSH
git config --global url."https://github.com/".insteadOf "[email protected]:"
# Or update package.json to use HTTPS URL{
"dependencies": {
"my-package": "git+https://github.com/user/repo.git"
}
}CI/CD Configuration:
For GitHub Actions:
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- run: npm ciPassphrase-Protected Keys: npm cannot prompt for SSH key passphrases. Either use a key without a passphrase (for automation) or ensure your ssh-agent has the key loaded.
Windows: Ensure OpenSSH Authentication Agent service is running:
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agentMultiple SSH Keys: If you have multiple keys, create ~/.ssh/config:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github_keynpm 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