Npm will not install express?

I currently have node.js version 0.8.8 and npm 1.1.59 installed.

Whenever I run:

$ npm install -g express 

I get this in return:

 npm ERR! Error: EACCES, open '/Users/devinandrews/.npm/64a534c1-express.lock' npm ERR! { [Error: EACCES, open '/Users/devinandrews/.npm/64a534c1-express.lock'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/Users/devinandrews/.npm/64a534c1-express.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" "-g" "express" npm ERR! cwd /Users/devinandrews npm ERR! node -v v0.8.8 npm ERR! npm -v 1.1.59 npm ERR! path /Users/devinandrews/.npm/64a534c1-express.lock npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, open '/Users/devinandrews/.npm/64a534c1-express.lock' npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/devinandrews/npm-debug.log npm ERR! not ok code 0 

I am pulling my hair out right now, trying to figure it out.

Update:

I ran

 $ npm -g ls 

to see that npm has been installed globally:

 /usr/local/lib β”œβ”€β”¬ express@3.0.0rc4 β”‚ β”œβ”€β”€ commander@0.6.1 β”‚ β”œβ”€β”¬ connect@2.4.4 β”‚ β”‚ β”œβ”€β”€ bytes@0.1.0 β”‚ β”‚ β”œβ”€β”€ formidable@1.0.11 β”‚ β”‚ β”œβ”€β”€ pause@0.0.1 β”‚ β”‚ └── qs@0.4.2 β”‚ β”œβ”€β”€ cookie@0.0.4 β”‚ β”œβ”€β”€ crc@0.2.0 β”‚ β”œβ”€β”€ debug@0.7.0 β”‚ β”œβ”€β”€ fresh@0.1.0 β”‚ β”œβ”€β”€ methods@0.0.1 β”‚ β”œβ”€β”€ mkdirp@0.3.3 β”‚ β”œβ”€β”€ range-parser@0.0.4 β”‚ └─┬ send@0.0.4 β”‚ └── mime@1.2.6 └─┬ npm@1.1.59 β”œβ”€β”€ abbrev@1.0.3 β”œβ”€β”€ ansi@0.1.2 β”œβ”€β”€ archy@0.0.2 β”œβ”€β”€ block-stream@0.0.6 β”œβ”€β”€ chownr@0.0.1 β”œβ”€β”€ couch-login@0.1.10 β”œβ”€β”€ fstream@0.1.18 β”œβ”€β”¬ fstream-npm@0.1.1 β”‚ └── fstream-ignore@0.0.5 β”œβ”€β”€ glob@3.1.12 β”œβ”€β”€ graceful-fs@1.1.10 β”œβ”€β”€ inherits@1.0.0 β”œβ”€β”€ ini@1.0.4 β”œβ”€β”¬ init-package-json@0.0.5 β”‚ └── promzard@0.2.0 β”œβ”€β”€ lockfile@0.2.1 β”œβ”€β”€ lru-cache@2.0.1 β”œβ”€β”€ minimatch@0.2.6 β”œβ”€β”€ mkdirp@0.3.4 β”œβ”€β”€ node-gyp@0.6.7 β”œβ”€β”€ nopt@2.0.0 β”œβ”€β”€ npm-registry-client@0.2.6 β”œβ”€β”¬ npmconf@0.0.11 β”‚ └─┬ config-chain@1.1.1 β”‚ └── proto-list@1.2.2 β”œβ”€β”€ npmlog@0.0.2 β”œβ”€β”€ once@1.1.1 β”œβ”€β”€ osenv@0.0.3 β”œβ”€β”¬ read@1.0.4 β”‚ └── mute-stream@0.0.3 β”œβ”€β”€ read-installed@0.0.2 β”œβ”€β”€ read-package-json@0.1.4 β”œβ”€β”€ request@2.9.203 β”œβ”€β”€ retry@0.6.0 β”œβ”€β”€ rimraf@2.0.2 β”œβ”€β”€ semver@1.0.14 β”œβ”€β”€ slide@1.1.3 β”œβ”€β”€ tar@0.1.13 β”œβ”€β”€ uid-number@0.0.3 └── which@1.0.5 

but if I run:

 $ npm ls 

does it return empty?

+46
express
Sep 01 '12 at 10:15
source share
8 answers

I had the same problem and npm cache clear did not fix it. This problem is caused because the .npm directory in your home directory was created with root privileges. Most likely, the first npm command you ran was sudo npm -g , and now you are trying to npm install in the local directory.

To solve:

  • sudo chown -R yourusername ~/.npm
  • This may be optional, but I also had rmdir ~/tmp

npm install from package.json should work after that.

+141
Dec 08
source share

run npm cache clean and try installing it again

+6
Sep 02
source share

I have the same problem, this problem is caused because the .npm directory in your home directory was created with root privileges.

use:

 $sudo npm install -g express 
+5
Dec 17 '12 at 19:14
source share

Have you tried sudo npm -g install express?

0
Sep 02 2018-12-12T00:
source share

Decision:

1 - order your user .npm folder:

 sudo chown -R Webmaste /Users/webmaste/.npm/ 

2 - In the test folder or your folder:

 sudo npm install -g express@2.5.8 

3 - Call express from your actual location:

 /usr/local/share/npm/bin/express 

four -

 sudo cd . && npm install 

5 - finally:

 node app 



The final message in the console should look like this:

 Express server listening on port 3000 in development mode 
0
Jan 28 '13 at 16:25
source share

If you don't see anything wrong with using sudo npm install -g package_name . And there is a problem with entering a password, which you can always add to sudoers files or to the same group that npm belongs to.

So, to add yourself to sudoers for npm edit /etc/sudoers adding something like this to the bottom of the file:

 your_username localhost=/usr/local/bin/npm 

Here's a step-by-step guide on how to achieve this if you need more details.

0
Nov 21 '13 at 1:14
source share

In my case, instead of the ~ / .npm directory owned by root, it was ~ / tmp, which I did not think to check until, finally, one of the error messages led me to search. The repair procedure is quite simple, since this is the tmp directory, we can just blow it away and start again with what belongs to you.

 sudo rmdir ~/tmp mkdir ~/tmp 
0
Apr 10 '14 at 2:13
source share

I ran into the same problem.

I updated the nodejs package by going to the node js download website and then I did not encounter this problem.

Thank. Good luck

0
Jan 22 '16 at
source share



All Articles