sudo curl | sh #1641

alexhuang91 opened this Issue Nov 2, 2011 · 21 comments


None yet

All clean!
npm ERR! Could not create /usr/lib/node_modules/___npm.npm
npm ERR! error installing npm@1.0.103 Error: EACCES, Permission denied '/usr/lib/node_modules'
npm ERR! Error: EACCES, Permission denied '/usr/lib/node_modules'
npm ERR! Report this entire log at:
npm ERR!
npm ERR! or email it to:
npm ERR!
npm ERR!
npm ERR! System Linux 3.0.0-12-generic
npm ERR! command "/usr/bin/node" "/tmp/npm.29786/package/cli.js" "install" "-gf"
npm ERR! cwd /tmp/npm.29786/package
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.103
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/npm.29786/package/npm-debug.log
npm not ok
It failed

bobrik commented Nov 2, 2011

curl | sudo sh

devansh commented Nov 2, 2011

Hi, I am a newbie to node.js and have installing npm for the first time and having some trouble using the one line install.

when i use the :

curl | sudo sh

I get nothing. (I mean the file is downloaded but then the prompt returns and npm is not installed)

and when i use:

curl | sh    # without sudo

I get the error :

failed to get tarball url for npm/latest

Please advise .TIA

I don't know whether this is the right post to bring this up or not because there was another similar post but that was closed issue and I did not have permission to reopen it. If I am wrong please redirect me to the correct post.

bobrik commented Nov 2, 2011

what about

sudo su
curl | sh
thejh commented Nov 2, 2011

Try this:

npm_debug=1 curl | sudo sh
isaacs commented Nov 2, 2011

@thejh The npm_debug=1 needs to be on the sh, as well, and requires a bash/zsh capable interpreter.

curl | sudo npm_debug=1 bash

@devansh What operating system are you seeing this no-output behavior on? A few people have reported similar results, and I can't seem to track it down. It always seems to work using bash in debug mode, so I'm guessing it's some kind of sh-related thing.

@isaacs isaacs closed this Nov 2, 2011
devansh commented Nov 3, 2011

Using the command you suggest says : curl couldn't connect to host


  1. when I use the debug mode the sh file still stops on " Failed to get tarball url for npm/latest" .
  2. I am using ubuntu server 10.04 on a virtual machine hosted on Windows XP(If relevant, my network adaptor for the VM is NAT).
  3. I have also tried installing by cloning from the git but that too gives me the following error after I sudo make install :

Clone of '' into submodule path 'node_modules/abbrev' failed

4.I also followed your instructions in #1540 where in you have told to use the following command:

(curl -SsL -k; echo "") | sed -e 's/^.*tarball":"//' | sed -e 's/".*$//' 

and i get the output as nothing. The prompt simply returns. I am at a loss on what to do. I need to install npm urgently. I thought of installing by downloading from tarball but the guy in issue#1540 had some issues with that too.But I guess I will give it a try too. TIA

devansh commented Nov 3, 2011

I also tried installing by downloading the tarball from : and then untar-ing it and then ./configure and sudo make install but I am having the same problem as issue#1540 (#1540)

devansh commented Nov 4, 2011

does it have to do something with me using http:// instead of https:// because https:// does not install? It says curl couldn't connect.

And moreover using the s command for getting the url does get me : when I use http:// instead of https://.

I guess I am right and also a complete novice if I understand it now that this might be a issue of my office network.

isaacs commented Nov 5, 2011

@devansh I think you are correct, and that this is a network issue on your end. I'm not sure how to help you.


@isaacs, @devansh I guess this is because of SSL certificate verification failure. curl performs it by default. Using -k option will turn off curl's verification of the certificate

devansh commented Nov 22, 2011

Yup, you are right. Had to set up proxy for https server too


had an issue with the installation due to proxy settings, but managed by adding '-E' to the sudo command. 'sudo -E' allows the proxy environment variables set in the normal user mode.
curl | sudo -E npm_debug=1 bash
... and i had to replace sh with bash (Ubuntu 11.10)


Hey guys, for posterity, now it's:

curl | sudo sh

homeboy's using ssl


And by the way, in case this helps anyone else out: It's possible to get into a weird wormhole where you start getting ENOENT and lstat errors and stuff, particularly if you've been "using" (npm link that is). I'm no expert on any of this stuff, but if you delete your ~/.npm folder, it seems to do the trick.

aclave1 commented Dec 6, 2013

I get this same issue, I fixed it with:

 curl -o 
 sudo chmod 777
 sudo ./

i'm getting same error
301 Moved Permanently
i tought that the page has been removed,

isaacs commented Feb 22, 2014

The page hasn't been removed. It's been moved. Permanently.

Add -L to your curl command.


Where has it been moved to?


Try this,,It will work..
sudo curl -k -L | sudo sh


I forgot how many times I runned npm update npm -g without sudo and got npm breaked because it unlinks everything at the beginning. So annoying.


Debashish. Thanks. I had the same issue.. it is simply moved and got it to work by this -L. Super.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment