How to fix npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry URL in npm

npmBEGINNERLOWUpdated Dec 5, 2025· 171 views

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
  1. Check current registry configuration
  2. Reset registry to default
  3. Check .npmrc files for errors
  4. Check for scoped registry errors
npm — error
# 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
npm ERR! code EINVALIDREGISTRYURL
npm 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

  1. Missing protocol in registry URL (e.g., 'registry.npmjs.org' instead of 'https://registry.npmjs.org')
  2. Extra quotes around URL in .npmrc (e.g., 'registry="https://..."')
  3. Trailing slashes or special characters in URL
  4. Empty registry value in configuration
  5. Corrupted package-lock.json with invalid URLs
  6. Conflicting environment variables (HTTP_PROXY, npm_config_registry)

How to fix "npm ERR! code EINVALIDREGISTRYURL npm ERR! Invalid registry URL"

1Check current registry configuration

View all npm configuration to find the invalid URL:

bash
# 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
2Reset registry to default

Clear any invalid registry and reset to default:

bash
# Delete custom registry setting
npm config delete registry

# Set to default npm registry
npm config set registry https://registry.npmjs.org/
3Check .npmrc files for errors

Inspect your .npmrc files for malformed URLs:

bash
# Check user-level config
cat ~/.npmrc

# Check project-level config
cat .npmrc

Common mistakes to fix:

bash
# Wrong - has quotes
registry="https://registry.npmjs.org"

# Wrong - missing protocol
registry=registry.npmjs.org

# Correct
registry=https://registry.npmjs.org/
4Check for scoped registry errors

If using scoped packages, verify the format:

bash
# Check scoped registry
npm config get @myorg:registry

Correct format in .npmrc:

bash
@myorg:registry=https://private-registry.example.com/

No quotes, must have protocol, scope must match exactly.

5Clear proxy settings if not needed

Invalid proxy URLs can also cause this error:

bash
npm config delete proxy
npm config delete https-proxy

# Also check environment variables
unset HTTP_PROXY
unset HTTPS_PROXY
unset npm_config_registry
6Clean and reinstall

After fixing configuration:

bash
# Delete potentially corrupted lock file
rm package-lock.json

# Clear npm cache
npm cache clean --force

# Reinstall
npm install

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

bash
env | grep -i npm
env | grep -i registry

Programmatic 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