我的Mac上安装了NodeJS。
$ node -v
v4.2.1
我试图安装凉亭。结果如下:
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/bower'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/bower']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/usr/local/lib/node_modules/bower' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/bower'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/bower']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back syscall: 'rmdir',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/bower' }
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Kevin/Sites/npm-debug.log
我试着这样做:
$ sudo chown -R $(whoami) ~/.npm
chown: /Users/Kevin/.npm/_locks: Operation not permitted
chown: /Users/Kevin/.npm/bower/1.6.3/package/package.json: Operation not permitted
chown: /Users/Kevin/.npm/bower/1.6.3/package: Operation not permitted
chown: /Users/Kevin/.npm/bower/1.6.3/package.tgz: Operation not permitted
chown: /Users/Kevin/.npm/bower/1.6.3: Operation not permitted
chown: /Users/Kevin/.npm/bower: Operation not permitted
chown: /Users/Kevin/.npm/n: Operation not permitted
好像我根本没有得到许可。 我无法安装任何东西。
我该如何解决?
答案 0 :(得分:5)
您可以在终端中运行以下命令来修复此权限错误。
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules
然后,您将不再需要在任何npm安装中使用sudo。
答案 1 :(得分:1)
我找到的唯一解决方案是重新安装mac OS X El Capitan。 之后它起作用了。
我现在正在使用docker再没有遇到这种问题。