Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission issues installing npm on OSX

Tags:

node.js

npm

I'm having issues installing the node package manager "npm".

On the website it prompts you to do a 1 line install as follows...

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

This spits out the following install error...

$ curl http://npmjs.org/install.sh | sh
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7184  100  7184    0     0  27012      0 --:--:-- --:--:-- --:--:-- 39256
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz
0.4.11
1.0.106
cleanup prefix=/usr

All clean!
npm ERR! Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "/usr/bin/node" "/private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package/cli.js" "rm" "npm" "-gf"
npm ERR! cwd /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.106
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package/npm-debug.log
npm not ok
npm ERR! error installing [email protected] Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! error rolling back [email protected] Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "/usr/bin/node" "/private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.106
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.72890/package/npm-debug.log
npm not ok

After googling around it looked like this is a common issue and the way of fixing it is to just run the same command prefaced with sudo.

Strangely, this doesn't seem to work in my case. This what happens if I run the same command sudo'd.

$ sudo curl http://npmjs.org/install.sh | sh
Password:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7184  100  7184    0     0   9974      0 --:--:-- --:--:-- --:--:-- 40359
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz
0.4.11
1.0.106
cleanup prefix=/usr

All clean!
npm ERR! Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "/usr/bin/node" "/private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package/cli.js" "rm" "npm" "-gf"
npm ERR! cwd /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.106
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package/npm-debug.log
npm not ok
npm ERR! error installing [email protected] Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! error rolling back [email protected] Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Error: EACCES, Permission denied '/usr/bin/npm'
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "/usr/bin/node" "/private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.106
npm ERR! path /usr/bin/npm
npm ERR! code EACCES
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/mn/8q6c34bj67xbxk08dwlsb_y40000gn/T/npm.81519/package/npm-debug.log
npm not ok
It failed

I'm drawing a blank here. Any ideas?

like image 354
Jon Avatar asked Dec 05 '11 03:12

Jon


1 Answers

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

It's sh that needs the permissions, not curl.

like image 115
Ricardo Tomasi Avatar answered Oct 01 '22 14:10

Ricardo Tomasi