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’m pulling my hair out right now trying to figure this out.
Update:
I ran
$ npm -g ls
to see my what npm has 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
it returns empty?
I had the same problem, and
npm cache cleardid not fix it. This problem is caused because the.npmdirectory in your home directory was created with root privileges. Most likely the first npm command you ran wassudo npm -gand now you are trying tonpm installin a local directory.To solve:
sudo chown -R yourusername ~/.npmrmdir ~/tmpnpm installfrom package.json should work after this.