Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to install npm via shell script on mac 10.6.4 and sudo does not seem to be working as the shell fails when trying to access /usr/lib and create documents in that directory. What is wrong?

fred:echowaves fred$ sudo curl http://npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3927  100  3927    0     0   3702      0  0:00:01  0:00:01 --:--:--  6975
fetching: http://registry.npmjs.org/npm/-/npm-1.0.22.tgz
0.4.10
1.0.22
prefix=/usr

This script will find and eliminate any shims, symbolic
links, and other cruft that was installed by npm 0.x.

Is this OK? enter 'yes' or 'no' 
es
Is this OK? enter 'yes' or 'no' 
yes

All clean!
! [ -d .git ] || git submodule update --init --recursive
node cli.js cache clean
node cli.js rm npm -g -f --loglevel error
node cli.js install -g -f
npm ERR! Could not create /usr/lib/node_modules/___npm.npm
npm ERR! error installing npm@1.0.22 Error: EACCES, Permission denied '/usr/lib/node_modules/___npm.npm'
npm ERR! Error: EACCES, Permission denied '/usr/lib/node_modules/___npm.npm'
npm ERR! 
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR! 
npm ERR!     sudo npm "install" "-g" "-f"
npm ERR! 
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR! 
npm ERR!     npm config set unsafe-perm true
npm ERR! 
npm ERR! System Darwin 11.0.0
npm ERR! command "node" "/private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package/cli.js" "install" "-g" "-f"
npm ERR! cwd /private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package
npm ERR! node -v v0.4.10
npm ERR! npm -v 1.0.22
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package/npm-debug.log
npm not ok
make: *** [install] Error 13
npm ERR! Could not create /usr/lib/node_modules/___npm.npm
npm ERR! error installing npm@1.0.22 Error: EACCES, Permission denied '/usr/lib/node_modules/___npm.npm'
npm ERR! Error: EACCES, Permission denied '/usr/lib/node_modules/___npm.npm'
npm ERR! 
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR! 
npm ERR!     sudo npm "install" "-gf"
npm ERR! 
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR! 
npm ERR!     npm config set unsafe-perm true
npm ERR! 
npm ERR! System Darwin 11.0.0
npm ERR! command "/usr/bin/node" "/private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package
npm ERR! node -v v0.4.10
npm ERR! npm -v 1.0.22
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package/npm-debug.log
npm not ok
It failed
fred:echowaves fred$ 
share|improve this question

migrated from stackoverflow.com Jul 31 '11 at 8:15

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

It looks like you're running the first part of the command (sudo curl http://npmjs.org/install.sh) as root, but then piping it to sh with your regular account permissions. Try splitting it up into two commands:

sudo curl -O http://npmjs.org/install.sh
sudo ./install.sh
share|improve this answer
    
I get sudo ./install.sh command not found? Sorry but I am new at this –  user852974 Jul 30 '11 at 2:42
    
Did you add the -O flag to curl in the first command? –  Asher L. Jul 30 '11 at 2:45
    
yes, I did sudo curl -O http://npmjs.org/install.sh –  user852974 Jul 30 '11 at 2:47
    
What's in the directory after you run the sudo curl ... command? What's the output of ls -l? –  Asher L. Jul 30 '11 at 2:52
add comment

Sudo only affects curl. You should switch to root before running the command. Type:

$ sudo su
root$ curl http://npmjs.org/install.sh | sh
root$ exit
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.