node.js 凉亭安装错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21616785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:48:47  来源:igfitidea点击:

Bower Installation Errors

macosnode.jsnpmbower

提问by Hurricane Development

Now I have installed Node and Npm and I run this command in terminal (yes I am on a mac):

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

npm install -g bower

Which follows with this output from the terminal:

以下是终端的输出:

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

回答by c0d3junk13

You need root access or permissions to install globally! Try :

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

 sudo npm install -g bower

回答by lrsjng

Much better than using sudois setting a user level prefix. For example in ~/.npmrcset:

比使用sudo设置用户级别前缀要好得多。例如在~/.npmrc集合中:

prefix = ${HOME}/npm-global

to use this folder for packages installed with -g.

将此文件夹用于安装有-g.

Then you also need to set your PATHenvironment variable to include ${HOME}/npm-global/bin.

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

回答by user3098588

you shouldn't sudo bower right? I mean sudo npm install -g bower will work BUT here's the message I got:

你不应该 sudo bower 吗?我的意思是 sudo npm install -g bower 可以工作,但这是我得到的消息:

Additional error details: Since bower is a user command, there is no need to execute it with superuser permissions. If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.

附加错误详情:由于 bower 是用户命令,因此无需以超级用户权限执行。如果您在不使用 sudo 的情况下使用 Bower 时遇到权限错误,请花几分钟时间了解更多有关您的系统应该如何工作并进行任何必要修复的信息。

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

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

You can however run a command with sudo using --allow-root option

但是,您可以使用 --allow-root 选项使用 sudo 运行命令

回答by jsol



If you've installed node/npm via Homebrew on OSX you may want to first run brew doctorand follow instructions before sudo-ing any system folders. In my case this brought up a nag about agreeing to an Xcode/iOS license:

如果您已经在 OSX 上通过 Homebrew 安装了 node/npm,您可能希望brew doctor在 sudo-ing 任何系统文件夹之前先运行并按照说明进行操作。就我而言,这引起了关于同意 Xcode/iOS 许可证的唠叨:

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

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

After doing that and running a brew updateI was able to install Bower globally as expected.

这样做并运行之后,brew update我能够按预期在全球范围内安装 Bower。

回答by Kasia B M

I know that it's an old thread but I run into the issue recently after reinstalling Yosemite and xCode tools. In case anyone else gets stuck, what helped me was using the commands:

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

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

Following suggestion from the thread below: https://github.com/bower/bower/issues/2262

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

回答by sfotiadis

Using sudowith npm is discouraged.

sudo不鼓励与 npm 一起使用。

Look here https://stackoverflow.com/a/18277225/1857521for a better solution to an almost identical problem.

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