本文介绍了安装 Yeoman - “找不到 Yo 命令"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 node.js 并使用 脚本.然后当我运行 npm install -g yo 时,我看到一堆内容在我的终端窗口中滚动,没有错误,然后就完成了.然后我输入 yo,OS X 告诉我它找不到命令.

I have installed node.js and set up npm on my Yosemite install using the npm-g_nosudo script. When I then run npm install -g yo I see a bunch of content scroll through my terminal window, with no errors, and it completes. I then type yo and OS X tells me that it can't find the command.

Sullys-MacBook-Pro:~ Sully$ npm install -g yo
/Users/Sully/npm/bin/yo -> /Users/Sully/npm/lib/node_modules/yo/lib/cli.js

> [email protected] postinstall /Users/Sully/npm/lib/node_modules/yo
> yodoctor


Yeoman Doctor
Running sanity checks on your system

✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory

Everything looks all right!
[email protected] /Users/Sully/npm/lib/node_modules/yo
├── [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], [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])
Sullys-MacBook-Pro:~ Sully$ yo
-bash: yo: command not found

我也尝试使用 source .bash_profile 并重新启动.仍然没有找到该命令.我做错了什么吗?

I also tried using source .bash_profile and rebooting. The command is still not found. Am I doing something wrong?

这是我的.bash_profile

# Add environment variable COCOS_CONSOLE_ROOT for cocos2d-x
export COCOS_CONSOLE_ROOT=/Users/Sully/Development/Libraries/cocos2d-x-3.5/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH

# Add environment variable COCOS_TEMPLATES_ROOT for cocos2d-x
export COCOS_TEMPLATES_ROOT=/Users/Sully/Development/Libraries/cocos2d-x-3.5/templates
export PATH=$COCOS_TEMPLATES_ROOT:$PATH

# NPM
export BIN_ROOT=/usr/local/bin
export PATH=$BIN_ROOT:$PATH

这是我的完整 $PATH

This is my full $PATH

Sullys-MacBook-Pro:~ Sully$ echo $PATH
/usr/local/share/npm/bin:/usr/local/bin:/Users/Sully/Development/Libraries/cocos2d-x-3.5/templates:/Users/Sully/Development/Libraries/cocos2d-x-3.5/tools/cocos2d-console/bin:/Users/Sully/.dnx/runtimes/dnx-mono.1.0.0-beta4/bin:/usr/local/bin:/Users/Sully/Development/Libraries/cocos2d-x-3.5/templates:/Users/Sully/Development/Libraries/cocos2d-x-3.5/tools/cocos2d-console/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

推荐答案

这是通过将 export PATH=/Users/UserAccountName/npm/bin:$PATH 添加到我的 ~/.bash_profile 并重新启动 Terminal.app.

This was resolved by adding export PATH=/Users/UserAccountName/npm/bin:$PATH to my ~/.bash_profile and restarting Terminal.app.

这篇关于安装 Yeoman - “找不到 Yo 命令"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 06:10