4

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

$cd ~/downloads/node
$./configure
$make
$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.

Alex
  • 8,111
  • 24
  • 71
  • 99

2 Answers2

1

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.

travis
  • 111
  • 2
  • 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 07:44
1

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
Passwort: 
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.