npm install without ssl

node.jsSslNpm

node.js Problem Overview


I have an Ubuntu VM that is having trouble connecting to sites with ssl, i.e. https. It can successfully download artifacts from the internet if the url begins with http.

npm install will download dependencies via https. Is there anyway make it download via http?

node.js Solutions


Solution 1 - node.js

Try changing the registry to the http version rather that the default https one using the command

npm config set registry http://registry.npmjs.org/

Solution 2 - node.js

As conlinf said, the following should work :

Now, to add my word, you should also consider that downloading without ssl allows a man-in-the-middle attack. It is only to add a warning to people who would read the post.

If you are a solo developer there should be not much trouble downloading in http directly, but if I wanted to attack a company using node.js I would consider delivering malicious code through npm... And performing such an attack without ssl will be much easier.

Solution 3 - node.js

After much trial and error I found that in addition to all that was said above, I also need to set the https-proxy to the value of the http proxy.

So the end .npmrc file looks like

proxy=http://username:[email protected]:port/
https-proxy=http://username:[email protected]:port/
strict-ssl=false
registry=http://registry.npmjs.org/

Note that proxy and https-proxy are identical!

See the comments on this thread for more info:

https://github.com/npm/npm/issues/8034

Also I ran a npm cache clean --force after updating the npmrc for good measure but I am not sure if it is required.

Hope that helps.

Solution 4 - node.js

changing ssl-strict worked for me behind a corporate firewall

npm config set ssl-strict=false

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKen HirakawaView Question on Stackoverflow
Solution 1 - node.jscolinfView Answer on Stackoverflow
Solution 2 - node.jsCreasixtineView Answer on Stackoverflow
Solution 3 - node.jsphyattView Answer on Stackoverflow
Solution 4 - node.jsJeremy FielView Answer on Stackoverflow