Setting the proxy configuration For Http proxy: Open your terminal and run the following command by replacing it with your proxy host and port. Now, you can install the npm packages behind the proxy by running an npm install <package-name> command. You can also read, how to clear a proxy in npm.
By running npm config rm proxy you remove proxy from user configuration. This can be easily verified by running: npm config list. If there is proxy or https-proxy setting set in global config you have to use --global in the command to remove it. Hope this is helpfull!!
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 pac
file in internet explorer lan settings and download the pac file from the URL configured.
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 active directory domain name is not required for the proxy, only the username and password (which may be different than your Active Directory login)
Don't forget to fiddle with escaping special password characters.
Download your .pac
file.
Open it in any editor and look for PROXY = "PROXY X.X.X.X:80;
.
You may have many proxies, copy any of them and run the following terminal commands:
npm config set proxy http://X.X.X.X:80
npm config set https-proxy http://X.X.X.X:80
Now you should be able to install any package!
I solved this problem this way:
1) I run this command:
npm config set strict-ssl false
2) Then set npm to run with http, instead of https:
npm config set registry "http://registry.npmjs.org/"
3) Then install your package
npm install <package name>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With