Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the latest version of stable node.js (0.8.19)

$cd ~/downloads/node
$sudo make install

Doing this installed node.js

Now, when I go to:

$cd ~/myproject/node_modules
$npm install express
npm ERR! Error: EACCES, open '/home/user/.npm/64a534c1-express.lock'
npm ERR!  { [Error: EACCES, open '/home/user/.npm/64a534c1-express.lock']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/home/user/.npm/64a534c1-express.lock' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.5.0-17-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "express"
npm ERR! cwd /home/user/myproject/src
npm ERR! node -v v0.8.15
npm ERR! npm -v 1.1.66
npm ERR! path /home/user/.npm/64a534c1-express.lock
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/home/user/.npm/64a534c1-express.lock'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/user/myproject/src/npm-debug.log
npm ERR! not ok code 0

See? for some reason I cannot install npm as a local user. However, when I use sudo npm install express, everything works.

share|improve this question
I don't understand your issue, once installed, you should be ok. – mdpc Feb 15 '13 at 7:31
Check your permissions. I'd bet /home/user/.npm/ or something in it is owned root rather than "user". – ceejayoz Mar 18 '13 at 20:55

I don't have an exact answer for you but a solution to allow you to install the module without running sudo is to make sure the directory you are working in contains a node_modules directory.

# ~ cd myproject
# ~/myproject mkdir node_modules
# ~/myproject npm install express

Notice how npm is being ran outside of the node_modules directory, one level up.

share|improve this answer
The problem is that express provides a nice binary helper, which you can not use (well, you can but you end up typing a butt tonne of characters) without installing with -g. on linux if you use -g then it tries to install to /usr/share/node_modules or somet root owned place. – airtonix Dec 29 '13 at 7:44

Error is thrown because /Users/yourname/.npm is not owned by yourname.

I had the same issue and did the following:

$: ls -lRa /Users/me/.npm/ | grep root
drwxr-xr-x    2 root   staff    68 26 Jun 14:08 _locks
drwxr-xr-x    2 root   staff    68 26 Jun 14:08 .

$: sudo chown me ./_locks
chown: ./_locks: No such file or directory

$: sudo chown me /Users/me/.npm/_locks/

$: sudo chown me /Users/me/.npm/

$: ls -lRa /Users/me/.npm/ | grep root
-- empty output --

After this, the install of everything went fine.

Why does this happen?

In the early usage of npm I invoked npm with sudo and lost my /npm/_locks.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.