The EINVALIDPROXY error occurs when npm detects malformed proxy settings in your configuration. This typically happens when the proxy URL is missing the protocol prefix (http:// or https://), contains unencoded special characters, or has incorrect formatting.
npm validates proxy configuration during package installation. When it encounters a proxy setting that doesn't follow the required URL format (protocol://[user:password@]host:port), it throws EINVALIDPROXY and halts the installation. This is a safety mechanism to prevent npm from attempting to use malformed proxy servers.
View your current npm configuration to identify the problematic proxy settings:
npm config listAlso check if proxy is set in environment variables:
# On Linux/macOS
echo $http_proxy
echo $https_proxyIf you're not behind a proxy or have invalid configuration, remove the proxy settings:
npm config delete proxy
npm config delete https-proxy
npm config delete http-proxyIf you need a proxy, ensure it follows the correct format:
# Basic format (no auth)
npm config set proxy http://proxyhost.com:8080
npm config set https-proxy http://proxyhost.com:8080
# With authentication
npm config set proxy http://username:[email protected]:8080Note: Always use http:// prefix for both proxy and https-proxy, not https://.
If your proxy password contains special characters, they must be URL-encoded:
- @ → %40
- # → %23
- : → %3A
- \\ → %5C
Example: If password is pass@word#123, set it as:
npm config set proxy http://user:pass%40word%[email protected]:8080If npm config commands don't work, manually edit your .npmrc file at ~/.npmrc:
proxy=http://proxyhost.com:8080
https-proxy=http://proxyhost.com:8080
strict-ssl=falseFor corporate environments with NTLM proxies, npm may not work directly. Install an intermediate proxy server like Cntlm that translates NTLM authentication to basic HTTP authentication, then point npm to your local proxy (e.g., http://localhost:3128). Some corporate networks also require strict-ssl=false in .npmrc to bypass certificate validation warnings.
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 ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error