This error occurs when npm cannot find a package in the registry. Common causes include typos in the package name, incorrect registry configuration, or trying to access private/scoped packages without authentication.
The E404 error in npm indicates that the npm registry returned a 404 HTTP status code, meaning the requested package could not be found at the specified URL. This is one of the most common npm errors developers encounter. When you run `npm install package-name`, npm sends a GET request to the registry (by default https://registry.npmjs.org/) to fetch the package metadata. If the registry responds with 404 Not Found, npm reports this error with the exact URL it tried to access. This error can occur for several reasons: the package name is misspelled, the package has been unpublished, you're using a corporate proxy that doesn't have the package, or you're trying to install a scoped package (like `@organization/package`) without proper authentication. Understanding the URL in the error message is key to diagnosing the issue.
First, confirm the package exists on npm by searching for it:
npm search package-nameOr visit https://www.npmjs.com/package/package-name in your browser.
Common typos to check:
- Transposed letters: lodash vs lodash
- Missing hyphens: createreactapp vs create-react-app
- Wrong scope: @angular/cli vs angular-cli
If you're using npx, check the command too:
# Wrong
npx crate-react-app my-app
# Correct
npx create-react-app my-appVerify which registry npm is using:
npm config get registryThe default should be https://registry.npmjs.org/. If it shows a different URL (like a corporate proxy), that may be the issue.
Reset to the default registry:
npm config set registry https://registry.npmjs.org/Also check for local .npmrc files that might override this:
# Check project directory
cat .npmrc
# Check home directory
cat ~/.npmrcA corrupted or stale cache can cause 404 errors. Clear it with:
npm cache clean --forceThen verify the cache is clean:
npm cache verifyAfter clearing the cache, try the install again:
npm installIf the error is for a scoped package (starting with @), you may need to authenticate.
For npm private packages:
npm loginFor GitHub Packages:
Create a .npmrc file with:
@OWNER:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_TOKENFor organization packages:
Ensure you have access to the organization and are logged in:
npm whoami
npm org ls your-orgNetwork issues can cause 404 errors. Test your connection:
# Test direct access to npm registry
curl -I https://registry.npmjs.org/
# Test a specific package
curl https://registry.npmjs.org/lodashIf you're behind a corporate proxy or VPN:
1. Try disconnecting from VPN temporarily
2. Configure npm to use your proxy:
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080Or use HTTP instead of HTTPS (less secure, for troubleshooting only):
npm config set registry http://registry.npmjs.org/An outdated npm version can sometimes cause registry issues:
npm install -g npm@latestOr if using Node.js with nvm:
nvm install-latest-npmVerify the update:
npm --version### Debugging Registry Requests
To see exactly what npm is doing, use the verbose flag:
npm install package-name --verboseThis shows the full HTTP request/response cycle, helping identify where the 404 originates.
### Corporate Registry/Proxy Issues
Many organizations use npm Enterprise, Artifactory, or Verdaccio as private registries. These proxies cache public packages but may not support:
- Newer packages (not yet cached)
- Scoped packages (requires configuration)
- Organization features
Work with your IT team to ensure the proxy is properly configured to forward requests to the public registry.
### Package Unpublishing
npm allows unpublishing packages within 72 hours of publishing. After that, packages cannot be easily unpublished. If you're seeing 404 for a package that previously existed:
1. Check if it was renamed (common with acquisitions)
2. Look for a deprecation notice on npmjs.com
3. Search for alternatives using npm search
### CI/CD Specific Issues
In CI/CD environments, 404 errors often occur due to:
1. Race conditions: Installing a package that was just published but not yet propagated
2. Token expiration: npm tokens have limited lifetimes
3. Network restrictions: CI runners may not have access to all registries
For CI, consider:
- Using npm ci instead of npm install for reproducible builds
- Caching node_modules between builds
- Setting up a local registry mirror
### Package-lock.json Conflicts
If your package-lock.json references a version that no longer exists:
# Remove lock file and node_modules
rm -rf node_modules package-lock.json
# Fresh install
npm installThis regenerates the lock file with currently available versions.
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