error installing npm@1.1.1 on Mac OS X Lion


I am trying to get going with express framework on Mac OS X Lion. Having these issues:

SilverFir-2:Node mike$ sudo curl | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7881  100  7881    0     0  29556      0 --:--:-- --:--:-- --:--:-- 43541
bsdtar 2.8.3 - libarchive 2.8.3
install npm@1.1
cleanup prefix=/usr/local

All clean!
npm ERR! Could not create /usr/local/lib/node_modules/___npm.npm
npm ERR! error installing npm@1.1.1

npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! 
npm ERR! System Darwin 11.3.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/6x/frvx23td327frc2z_hgl12sc0000gn/T/npm.3230/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/6x/frvx23td327frc2z_hgl12sc0000gn/T/npm.3230/package
npm ERR! node -v v0.6.1
npm ERR! npm -v 1.1.1
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! message EACCES, permission denied '/usr/local/lib/node_modules'
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/6x/frvx23td327frc2z_hgl12sc0000gn/T/npm.3230/package/npm-debug.log
npm not ok
It failed

Node version v0.6.1.

I looked around on the web and most of the answers are from node 0.4 days and they all just say upgrade. It looks like I am more up to date than those previous questions...

Problem courtesy of: mikebz


When you do this:

sudo curl | sh

You will run curl as root, but sh as your current user. You should do this instead:

curl | sudo sh

And all will be well.

Solution courtesy of: Linus Gustav Larsson Thiel


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.