Cannot install NPM using curl

The original command would work if you use the current location (and not the old one) (at least on my system, same settings). Meaning, use:

curl https://npmjs.org/install.sh | sh

instead of:

curl http://npmjs.org/install.sh | sh

I have tried many times with various curl options. But the main problem is npm site's https certificate verification. Finally this has worked for me:

curl -k -O -L https://npmjs.org/install.sh

Hope it will help somebody else.


You are getting the install.sh script, you just have to execute it. Do this

curl -O https://npmjs.org/install.sh
sudo sh install.sh

Update

If you get a 301 Moved Permanently file instead, try adding -L option to follow the redirect like this:

curl -O -L https://npmjs.org/install.sh

Tags:

Bash

Node.Js

Npm