I need to download several packages through npm but our corporate proxy configuration is a .pac file (i'm on windows)
i already tried
npm config set proxy http://mydomain\username:password@1.2.3.4:8181/proxy.pac
npm config set https-proxy http://mydomain\username:password@1.2.3.4:8181/proxy.pac
or
npm config set proxy http://1.2.3.4:8181/proxy.pac
npm config set https-proxy http://1.2.3.4:8181/proxy.pac
buth it doesn't work...
any suggestion? thanks
I've just had a very similar problem, where I couldn't get npm to work behind our proxy server.
My username is of the form "domain\username" - including the slash in the proxy configuration resulted in a forward slash appearing. So entering this:
npm config set proxy "http://domain\username:password@servername:port/"
then running this "npm config get proxy" returns this: http://domain/username:password@servername:port/
Therefore to fix the problem I instead URL encoded the backslash, so entered this:
npm config set proxy "http://domain%5Cusername:password@servername:port/"
and with this the proxy access was fixed.
Look for the url of the pack file in internet explorer lan settings and download the pack file. The pac file is just a javascript file with a function named FindProxyForURL which returns different proxy hosts in different scenarios.
Try to find a host in that pac file which you think is for general web traffic and plug it into .npmrc in C:\Users\<username>\.npmrc
proxy=http://<username>:<pass>@proxyhost:<port>
https-proxy=http://<uname>:<pass>@proxyhost:<port>
Even though you may login with your domain and username on your corporate machine It is highly possible that the user domain name is not required for the proxy, only the username and password (which may be different than your Active Directory login)
Don't foget to fiddle with escaping special password characters.
just download your .pac
file.
open it in any editor. and look for PROXY = "PROXY X.X.X.X:80;
you may have many proxy copy any one of them
then run following cmds
npm config set proxy=http://X.X.X.X:80/
npm config set https-proxy http://X.X.X.X:80;
then try to install your desired package. it works
You will get the proxy host and port from your server administrator or support.
After that set up
npm config set http_proxy http://username:password@proxyofmycomp.com:itsport
npm config set proxy http://username:password@proxyofmycomp.com:itsport
If there any special character in password try with % urlencode. Eg:- pound(hash) shuold be replaced by %23.
This worked for me...