How to fix npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry URL in npm
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.
Quick fix
Fixes npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry 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 -l- Check current registry configuration
- Reset registry to default
- Check .npmrc files for errors
- Check for scoped registry errors
# Show current registrynpm config get registry# Show all configuration (look for registry entries)npm config list# Show all configuration including defaultsnpm config list -lnpm ERR! code EINVALIDREGISTRYURLnpm ERR! Invalid registry URL
What this error means
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`.
Typical symptoms
- npm install fails with 'EINVALIDREGISTRYURL'
- Error shows 'Invalid registry URL'
- npm commands fail before making any network requests
- Started after editing .npmrc or npm configuration
Common causes
- Missing protocol in registry URL (e.g., 'registry.npmjs.org' instead of 'https://registry.npmjs.org')
- Extra quotes around URL in .npmrc (e.g., 'registry="https://..."')
- Trailing slashes or special characters in URL
- Empty registry value in configuration
- Corrupted package-lock.json with invalid URLs
- Conflicting environment variables (HTTP_PROXY, npm_config_registry)
How to fix "npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry URL"
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 installAdvanced notes
Configuration 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.
Frequently asked questions
- What does "npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry URL" mean?
- 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. json.
- How do I fix "npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry URL"?
- 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.
- What causes "npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry URL"?
- Missing protocol in registry URL (e.g., 'registry.npmjs.org' instead of 'https://registry.npmjs.org') Extra quotes around URL in .npmrc (e.g., 'registry="https://..."') Trailing slashes or special characters in URL
- Is the "npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry URL" error serious?
- It is a low-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖Docs: npmrc configuration(Official Docs)
- 📖Docs: npm config command(Official Docs)
- 💬SO: npm registry configuration(Stack Overflow)