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