问题描述
我目前有node.js版本0.8.8,安装了npm 1.1.59。
每当我运行:
$ npm install -g express
我得到这个回报:
npm ERR!错误:EACCES,打开'/Users/devinandrews/.npm/64a534c1-express.lock'
npm ERR! {[错误:EACCES,打开'/Users/devinandrews/.npm/64a534c1-express.lock']
npm ERR! errno:3,
npm ERR!代码:'EACCES',
npm ERR!路径:'/Users/devinandrews/.npm/64a534c1-express.lock'}
npm ERR!
npm ERR!请尝试以root用户/管理员身份重新运行此命令。
npm ERR!系统达尔文12.1.0
npm ERR!命令node/ usr / local / bin / npminstall-gexpress
npm ERR! cwd / Users / devinandrews
npm ERR!节点-v v0.8.8
npm ERR! npm -v 1.1.59
npm ERR!路径/Users/devinandrews/.npm/64a534c1-express.lock
npm ERR!代码EACCES
npm ERR!错误3
npm ERR!堆栈错误:EACCES,打开'/Users/devinandrews/.npm/64a534c1-express.lock'
npm ERR!
npm ERR!额外的日志记录详细信息可以在以下位置找到:
npm ERR! /Users/devinandrews/npm-debug.log
npm ERR!不确定代码0
我正在拉我的头发,现在试图弄清楚这一点。
更新:
我跑了
$ npm -g ls
查看我的全球npm安装:
/ usr / local / lib
├─┬[email protected]
│├─ ─[email protected]
│├─┬[email protected]
││├──[email protected]
││├──[email protected]
││├──[email protected]
││└──[email protected]
│├──[email protected]
│├──[email protected]。 0
│├──[email protected]
│├──[email protected]
│├──[email protected]
│├──mkdirp @ 0.3.3
│├──[email protected]
│└─┬[email protected]
│└──[email protected]
└─ ┬[email protected]
├──[email protected]
├──[email protected]
├──[email protected]
├──块[email protected]
├──[email protected]
├──[email protected]
├──[email protected]
├ ┬[email protected]
│└──[email protected]
├──[email protected]
├──[email protected]
├──[email protected]
├──[email protected]
├─┬[email protected]
│└──[email protected] .0
├──[email protected]
├──[email protected]
├──[email protected]
├──[email protected] .4
├──[email protected]
├──[email protected]
├──[email protected]
├─ ┬[email protected]
│└─┬[email protected]
│└──[email protected]
├──[email protected]
├──[email protected]
├──[email protected]
├─┬[email protected]
│└──[email protected]
├──[email protected]
├──[email protected]
├──[email protected]
├──重试@ 0.6.0
├──[email protected]
├──[email protected]
├──[email protected]
├──[email protected]
├──[email protected]
└──[email protected]
但是如果我运行:
$ npm ls
它返回空?
我有同样的问题,而 npm缓存清除
没有修复它。这是因为您的主目录中的 .npm
目录是使用root权限创建的。最可能的是您运行的第一个npm命令是 sudo npm -g
,现在您正尝试在本地的 npm安装
目录。
要解决:
-
sudo chown -R yourusername〜/ .npm
- 这可能不是必需的,但我也不得不
rmdir〜/ tmp
npm install
/ p>
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
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
but if i run:
$ npm ls
it returns empty?
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 a local directory.
To solve:
sudo chown -R yourusername ~/.npm
- This may not be necessary but I also had to
rmdir ~/tmp
npm install
from package.json should work after this.
这篇关于npm不会安装快递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!