This error occurs when npm encounters a malformed registry URL in your configuration. Usually caused by typos in .npmrc, missing protocol, extra quotes, or corrupted settings.
npm validates registry URLs before making requests. The EINVALIDREGISTRYURL error means a registry URL in your configuration is malformed—it might be missing the `https://` protocol, have extra characters, contain quotes, or be completely empty. This error can come from multiple configuration sources: your project's `.npmrc`, your user `~/.npmrc`, environment variables, or even a corrupted `package-lock.json`.
View all npm configuration to find the invalid URL:
# Show current registry
npm config get registry
# Show all configuration (look for registry entries)
npm config list
# Show all configuration including defaults
npm config list -lClear any invalid registry and reset to default:
# Delete custom registry setting
npm config delete registry
# Set to default npm registry
npm config set registry https://registry.npmjs.org/Inspect your .npmrc files for malformed URLs:
# Check user-level config
cat ~/.npmrc
# Check project-level config
cat .npmrcCommon mistakes to fix:
# Wrong - has quotes
registry="https://registry.npmjs.org"
# Wrong - missing protocol
registry=registry.npmjs.org
# Correct
registry=https://registry.npmjs.org/If using scoped packages, verify the format:
# Check scoped registry
npm config get @myorg:registryCorrect format in .npmrc:
@myorg:registry=https://private-registry.example.com/No quotes, must have protocol, scope must match exactly.
Invalid proxy URLs can also cause this error:
npm config delete proxy
npm config delete https-proxy
# Also check environment variables
unset HTTP_PROXY
unset HTTPS_PROXY
unset npm_config_registryAfter fixing configuration:
# Delete potentially corrupted lock file
rm package-lock.json
# Clear npm cache
npm cache clean --force
# Reinstall
npm installConfiguration Priority: npm reads configuration from multiple sources (highest to lowest priority):
1. Command line flags
2. Environment variables (npm_config_*)
3. Project .npmrc
4. User ~/.npmrc
5. Global npmrc
6. Built-in defaults
Valid URL Format: Registry URLs must:
- Start with http:// or https://
- Have no quotes
- Optionally end with /
- Contain no spaces or special characters
Environment Variables: Environment variables like npm_config_registry override .npmrc files. Check with:
env | grep -i npm
env | grep -i registryProgrammatic Access: If this occurs in a script, ensure any registry URLs are properly URL-encoded and have the protocol prefix.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
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 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 ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"