凉亭安装错误

时间:2014-02-07 00:08:43

标签: macos node.js npm bower

现在我已经安装了Node和Npm,我在终端运行这个命令(是的,我在Mac上):

npm install -g bower

以下来自终端的输出:

npm http GET https://registry.npmjs.org/bower
npm http 304 https://registry.npmjs.org/bower
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/bower']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/bower',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/bower',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! cwd /Users/Superfunnytogo
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! fstream_path /usr/local/lib/node_modules/bower
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/Superfunnytogo/npm-debug.log
npm ERR! not ok code 0
Device-365-352:~ Superfunnytogo$ npm install -g bower
npm http GET https://registry.npmjs.org/bower
npm http 304 https://registry.npmjs.org/bower
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/bower']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/bower',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/bower',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! cwd /Users/Superfunnytogo
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! fstream_path /usr/local/lib/node_modules/bower
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/Superfunnytogo/npm-debug.log
npm ERR! not ok code 0

6 个答案:

答案 0 :(得分:89)

您需要root访问权限或权限才能全局安装!试试:

 sudo npm install -g bower

答案 1 :(得分:19)

比使用sudo更好的是设置用户级前缀。例如,在~/.npmrc集合中:

prefix = ${HOME}/npm-global

将此文件夹用于与-g一起安装的软件包。

然后,您还需要将PATH环境变量设置为包含${HOME}/npm-global/bin

答案 2 :(得分:4)

你不应该sudo凉亭吗?我的意思是sudo npm install -g bower将工作但是这里是我得到的消息:

其他错误详情: 由于bower是用户命令,因此无需使用超级用户权限执行它。 如果您在使用没有sudo的凉亭时遇到权限错误,请花几分钟时间了解您的系统应如何工作并进行必要的维修。

http://www.joyent.com/blog/installing-node-and-npm https://gist.github.com/isaacs/579814

但是,您可以使用--allow-root选项

运行带有sudo的命令

答案 3 :(得分:1)


如果您在OSX上通过Homebrew安装了node / npm,您可能需要先运行brew doctor并按照说明操作任何系统文件夹。在我的情况下,这提出了一个关于同意Xcode / iOS许可证的唠叨:

Builds will fail! Agree to the license by opening Xcode.app or running: xcodebuild -license

执行此操作并运行brew update后,我能够按预期全局安装Bower。

答案 4 :(得分:1)

我知道它是一个旧线程,但我在重新安装Yosemite和xCode工具后最近遇到了这个问题。如果其他人被卡住,帮助我的是使用命令:

sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config

遵循以下主题的建议: https://github.com/bower/bower/issues/2262

答案 5 :(得分:0)

不鼓励使用sudo和npm。

在这里查看https://stackoverflow.com/a/18277225/1857521,以便更好地解决几乎相同的问题。