Read about a proxy variable in a .npmrc
file but it does not work. Trying to avoid manually downloading all require packages and installing.
For me even though python etc will all work though our corporate proxy npm would not.
I tried
npm config set proxy http://proxyccc.xxx.ca:8080
npm config set https-proxy https://proxyccc.xxx.ca:8080
npm config set registry http://registry.npmjs.org/
as instructed but kept getting the same error.
It was only when I removed
https-proxy https://proxyccc.xxx.ca:8080
from the .npmrc file
that
npm install electron --save-dev worked
After tying different answers finally, @Kayvar answers's first four lines help me to solve the issue:
npm config set registry http://registry.npmjs.org/
npm config set proxy http://myusername:mypassword@proxy.us.somecompany:8080
npm config set https-proxy http://myusername:mypassword@proxy.us.somecompany:8080
npm config set strict-ssl false
There is good information on curl's page on SSL and certificate issues. I base most of my answer on the information there.
Using strict-ssl false is bad practice and can create issues. What we can do instead is add the certificate that is being injected, by the "man in the middle" certificate.
How to solve this on Windows:
openssl x509 -inform DES -in **rootcert**.cer -out outcert.pem -text
npm config set cafile **C:\Users\username\cacert.pem
npm config set strict-ssl true
Phew! We made it! Now npm can understand how to connect. Bonus is that you can tell curl to use the same cabundle.pem and it will also understand HTTPs.
I tried all of these options, but my proxy wasn't having any of it for some reason. Then, born out of desparation/despair, I randomly tried curl
in my Git Bash shell, and it worked.
Unsetting all of the proxy options using
npm config rm proxy
npm config rm https-proxy
And then running npm install
in my Git Bash shell worked perfectly. I don't know how it's set up correctly for the proxy and the Windows cmd
prompt isn't, but it worked.
Try to find .npmrc in C:\Users\.npmrc
then open (notepad), write, and save inside :
proxy=http://<username>:<pass>@<proxyhost>:<port>
PS : remove "<" and ">" please !!
In my case, I forgot to set the "http://" in my config files (can be found in C: \Users \ [USERNAME] \ .npmrc) proxy adresses. So instead of having
proxy=http://[IPADDRESS]:[PORTNUMBER]
https-proxy=http://[IPADDRESS]:[PORTNUMBER]
I had
proxy=[IPADDRESS]:[PORTNUMBER]
https-proxy=[IPADDRESS]:[PORTNUMBER]
Which of course did not work, but the error messages didnt help much either...