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 error code ENOENT npm error syscall spawn git npm error path git npm error errno -4058 npm error enoent An unknown git error occurred
How to fix "spawn git ENOENT" in npm
npm error code E401 npm error Incorrect or missing password.
How to fix 'E401 Unable to authenticate' errors with npm private registries
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