bash 安装 yeoman 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20330273/
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
Error installing yeoman
提问by user1498724
Installing Yeoman on my OSX machine results in the following error:
在我的 OSX 机器上安装 Yeoman 会导致以下错误:
paulh16$ npm install -g yo
npm http GET https://registry.npmjs.org/yo
npm http 304 https://registry.npmjs.org/yo
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/yo'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/yo']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/yo',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/yo',
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" "yo"
npm ERR! cwd /Users/paulh16/.rvm/lib
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! path /usr/local/lib/node_modules/yo
npm ERR! fstream_path /usr/local/lib/node_modules/yo
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/yo'
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/paulh16/.rvm/lib/npm-debug.log
npm ERR! not ok code 0
I believe the problem is that bash is looking for npm within the Ruby Version Manager, which is where I installed node and npm originally. However, I removed both from RVM and installed from the Node website. I also adjusted my .bash_profile:
我相信问题在于 bash 正在 Ruby 版本管理器中寻找 npm,这是我最初安装 node 和 npm 的地方。但是,我从 RVM 中删除并从 Node 网站安装。我还调整了我的 .bash_profile:
PS1="\u$ "
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM$
I don't understand why the Yeoman installation is failing.
我不明白为什么 Yeoman 安装失败。
回答by Drew Hart
This solved the issue for me. Setting the permission on the npm folder in your home directory was the fix for me.
这为我解决了这个问题。在你的主目录中设置 npm 文件夹的权限对我来说是修复。
sudo chown -R `whoami` ~/.npm
回答by Paul Mougel
The npm
command fails because you need to be root to edit files under /usr/
.
该npm
命令失败,因为您需要以 root 身份编辑/usr/
.
You should properly configure npm
, see this relevant SO answer:
您应该正确配置npm
,请参阅此相关 SO 答案:
$ echo prefix = ~/.node >> ~/.npmrc
回答by Maysam Torabi
try
尝试
sudo chown -R $USER /usr/local
sudo chown -R $USER /usr/local
and this kind of problem would be solved forever
这样的问题将永远得到解决
it's not encouraged to npm with sudo
不鼓励使用 sudo npm
回答by svnm
For me on Ubuntu only the following worked for me...
对于我在 Ubuntu 上只有以下对我有用......
Ubuntu
Ubuntu
Tested on Ubuntu 14.04.2
在 Ubuntu 14.04.2 上测试
This was a base install of Ubuntu 14.04.2 on VirtualBox using ubuntu-trusty-64.
这是使用 ubuntu-trusty-64 在 VirtualBox 上基本安装 Ubuntu 14.04.2。
I had just installed node and npm fresh and they were working well.
我刚刚安装了 node 和 npm fresh,它们运行良好。
npm install -y -g yo
echo export PATH="$HOME/npm/bin:$PATH" >> ~/.bashrc
npm config set prefix ~/npm
echo "export NODE_PATH=$NODE_PATH:/home/$USER/npm/lib/node_modules" >> ~/.bashrc && source ~/.bashrc
npm install -y -g yo
yes I had to install yeoman, fix the path issues, then reinstall yeoman. based on some answers on this stack overflow post
是的,我必须安装 yeoman,修复路径问题,然后重新安装 yeoman。基于此堆栈溢出帖子的一些答案
回答by Mitchell Hudson
This worked well for me:
这对我来说效果很好:
sudo npm install -g yo