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 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
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm