This error occurs when npm cannot find or access the registry configured for a package, typically due to missing .npmrc configuration, incorrect registry URLs, or authentication issues. npm needs a valid registry URL to download packages.
The EREGISTRYMISSING error means npm is unable to locate or connect to the package registry required to install a package. This commonly happens with scoped packages (like @mycompany/package-name) that require a custom private registry, but npm doesn't have the registry configuration in its .npmrc file. The error can also occur when the default npm registry URL is missing, corrupted, or unreachable. npm needs to know which registry server to contact to fetch package metadata and code. Without this configuration, npm cannot proceed with installation. For scoped packages, npm looks for a specific registry URL in the .npmrc file prefixed with the scope name.
First, verify what registry npm is currently configured to use:
npm config listLook for the registry line in the output. It should show something like:
registry = "https://registry.npmjs.org/"If you don't see a registry line or see an error, npm is missing registry configuration.
If the registry is missing or corrupted, set it back to the official npm registry:
npm config set registry https://registry.npmjs.org/For scoped packages that use a private registry, also configure the scope:
npm config set @mycompany:registry https://your-private-registry.com/Verify the configuration was set correctly:
npm config get registryFor projects using private registries, create a .npmrc file in your project root:
# For public packages from npm
registry=https://registry.npmjs.org/
# For scoped private packages
@mycompany:registry=https://your-private-registry.com/
# Authentication token for private registry
//your-private-registry.com/:_authToken=YOUR_AUTH_TOKEN_HEREIMPORTANT:
- File must be named exactly .npmrc (not .npmrc.txt)
- Use correct syntax: @scope:registry= not @scope=
- Auth tokens must be prefixed with // and include _authToken
After updating your registry configuration, clean the npm cache and attempt installation again:
npm cache clean --force
rm package-lock.json
rm -rf node_modules/
npm installOr specify the registry directly in the install command:
npm install --registry=https://registry.npmjs.org/If you're using a private registry, verify you're logged in and the registry is accessible:
npm login --registry=https://your-private-registry.com/ --scope=@mycompany
curl -H "Authorization: Bearer YOUR_TOKEN" https://your-private-registry.com/
npm cache verifyFor GitHub Packages, use a GitHub personal access token with read:packages permissions.
On Windows, the .npmrc file must be created via command line or a code editor (not Windows Explorer) because Windows doesn't natively support files with only a dot prefix. A common mistake is the file being saved as .npmrc.txt instead. On macOS, TextEdit may save as .npmrc.rtf with garbage characters - use VSCode or command line instead. For CI/CD environments, pass credentials securely via environment variables rather than hardcoding tokens in .npmrc files.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error