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 ?
npm installs packages locally within your projects by default. You can also install packages globally (e.g. npm install -g <package> ) (useful for command-line apps). However the downside of this is that you need to be root (or use sudo ) to be able to install globally.
You should not run applications with root privileges if its not necessary. Node and npm can do their work just perfectly fine without admin powers.
Running sudo npm install -g seems to be pretty common advice on the Internet. mean.io, a prominent web framework compilation generator/library even suggests doing it on their own homepage. Using sudo npm install (and potentially sudo npm <anything> ) is a bad idea ™.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With