The HTTP 429 Too Many Requests error occurs when you've exceeded npm registry rate limits. This is common in CI/CD environments with many concurrent jobs or during aggressive scripting.
HTTP 429 is a rate limiting response - you've made too many requests to the npm registry in a short time period. The registry implements rate limiting to ensure fair access for all users and protect against abuse. Rate limits apply to both authenticated and anonymous users, with authenticated users typically getting higher limits. CI/CD environments often hit these limits due to parallel jobs all requesting packages simultaneously.
Respect the rate limit:
# Check retry-after header (if present)
# Wait the specified time, then retry
sleep 60
npm installRate limits typically reset within minutes.
Cache packages to reduce requests:
# Local cache is automatic, but verify
npm config get cache
# Force cache usage
npm install --prefer-offlineOptimize CI/CD:
# GitHub Actions
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- run: npm ciLog in for increased rate limits:
npm login
# Or use token in CI
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKENLimit concurrency:
# Reduce concurrent connections
npm config set maxsockets 3
# In CI, stagger job starts
# Or use a single install job that cachesUse a caching proxy:
# Use Verdaccio, Nexus, or Artifactory as proxy
npm config set registry http://npm-proxy.company.comThis reduces direct registry requests.
For large organizations, npm Enterprise or a self-hosted registry eliminates public rate limits. Consider using pnpm or yarn which have different request patterns. In Kubernetes, use a shared npm cache volume or service. Monitor registry response headers for rate limit information. GitHub Actions cache can persist across workflow runs.
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm