NPM always asks me a root in an Express project

advertisements

Since I use Express.js, I can't use npm install normally anymore. I always have to go root for it to work...

Let's say I generate a projet with

express --sessions --css css

When I try to do a npm install after, I've got these errors

npm WARN package.json [email protected] No README.md file found!
npm ERR! Error: EACCES, open '/Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock'
npm ERR!  { [Error: EACCES, open '/Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/Arnaud/Sites/test
npm ERR! node -v v0.10.2
npm ERR! npm -v 1.2.15
npm ERR! path /Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/Arnaud/Sites/test/npm-debug.log
npm ERR! not ok code 0

But if do a sudo npm install, it's all good... Any idea why ?


This is probably a permissions issue. To reclaim ownership of the /Users/Arnaud/.npm directory execute the following command in the terminal

chown -R Arnaud /Users/Arnaud/.npm

If you are on OSX you can also use Disk Utility to repair permissions across the entire disk, which will probably fix the issue for you as well.