Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm won't install from package.json within project

On my macbook air I can only install npm packages globally using sudo but anytime I go into a local directory and try to install a local package without the -g it gives me errors.

 npm ERR! Error: EACCES, open '/Users/mmarze/.npm/53951495-coffee-script.lock'
npm ERR!  { [Error: EACCES, open '/Users/mmarze/.npm/53951495-coffee-script.lock']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/mmarze/.npm/53951495-coffee-script.lock' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "coffee-script"
npm ERR! cwd /Users/mmarze/sandbox/node.js/test
npm ERR! node -v v0.8.9
npm ERR! npm -v 1.1.61
npm ERR! path /Users/mmarze/.npm/53951495-coffee-script.lock
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Users/mmarze/.npm/53951495-coffee-script.lock'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/mmarze/sandbox/node.js/test/npm-debug.log
npm ERR! not ok code 0

I tried uninstalling and reinstalling node and npm and I can't get it to install anything locally, and if I use sudo to install locally then my local user doesn't have write access to them. How can I fix this?

like image 937
Mmarzex Avatar asked Sep 21 '12 14:09

Mmarzex


1 Answers

Based on the comment from Linus G Thiel it looks like this fixes the issue:

Looks like you may have done a sudo npm install ... without -g, i.e. installed npm packages in your home as the root user. Either clear your .npm directory or chown -R mmarze.mmarze ~/.npm should fix it.

like image 129
Jacob Avatar answered Sep 22 '22 03:09

Jacob