安装 Yeoman - "Yo command not found"
Installing Yeoman - "Yo command not found"
我已经安装了 node.js
并使用 npm-g_nosudo 脚本在我的 Yosemite 安装中设置了 npm
。当我然后 运行 npm install -g yo
时,我看到一堆内容在我的终端 window 中滚动,没有错误,它完成了。然后我输入 yo
和 OS X 告诉我它找不到命令。
Sullys-MacBook-Pro:~ Sully$ npm install -g yo
/Users/Sully/npm/bin/yo -> /Users/Sully/npm/lib/node_modules/yo/lib/cli.js
> yo@1.4.6 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!
yo@1.4.6 /Users/Sully/npm/lib/node_modules/yo
├── titleize@1.0.0
├── array-uniq@1.0.2
├── figures@1.3.5
├── user-home@1.1.1
├── opn@1.0.2
├── humanize-string@1.0.1 (decamelize@1.0.0)
├── sort-on@1.2.0 (dot-prop@2.0.0)
├── async@0.9.0
├── yeoman-character@1.0.1 (supports-color@1.3.1)
├── string-length@1.0.0 (strip-ansi@2.0.1)
├── cross-spawn@0.2.9 (lru-cache@2.6.2)
├── findup@0.1.5 (commander@2.1.0, colors@0.6.2)
├── chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
├── yosay@1.0.3 (ansi-regex@1.1.1, ansi-styles@2.0.1, strip-ansi@2.0.1, word-wrap@1.0.3, pad-component@0.0.1, taketalk@1.0.0, minimist@1.1.1)
├── root-check@1.0.0 (downgrade-root@1.1.0, sudo-block@1.2.0)
├── meow@3.1.0 (object-assign@2.0.0, camelcase-keys@1.0.0, minimist@1.1.1, indent-string@1.2.1)
├── package-json@1.1.0 (registry-url@3.0.3)
├── npm-keyword@1.1.1 (registry-url@3.0.3)
├── update-notifier@0.3.2 (is-npm@1.0.0, latest-version@1.0.0, semver-diff@2.0.0)
├── got@2.9.2 (lowercase-keys@1.0.0, timed-out@2.0.0, object-assign@2.0.0, is-stream@1.0.1, prepend-http@1.0.1, nested-error-stacks@1.0.0, statuses@1.2.1, infinity-agent@2.0.3, duplexify@3.3.0, read-all-stream@2.1.2)
├── fullname@1.1.0 (npmconf@2.1.1)
├── yeoman-environment@1.2.5 (log-symbols@1.0.2, escape-string-regexp@1.0.3, untildify@2.0.0, diff@1.4.0, text-table@0.2.0, debug@2.1.3, mem-fs@1.1.0, globby@1.2.0, grouped-queue@0.3.0)
├── configstore@0.3.2 (object-assign@2.0.0, xdg-basedir@1.0.1, osenv@0.1.0, graceful-fs@3.0.6, uuid@2.0.1, mkdirp@0.5.0, js-yaml@3.3.0)
├── insight@0.5.3 (object-assign@2.0.0, lodash.debounce@3.0.3, os-name@1.0.3, tough-cookie@0.12.1, request@2.55.0)
├── lodash@3.8.0
├── yeoman-doctor@1.3.2 (object-values@1.0.0, log-symbols@1.0.2, each-async@1.1.1, twig@0.7.2)
└── inquirer@0.8.3 (ansi-regex@1.1.1, cli-width@1.0.1, through@2.3.7, readline2@0.1.1, rx@2.5.2)
Sullys-MacBook-Pro:~ Sully$ yo
-bash: yo: command not found
我也尝试过使用 source .bash_profile
并重新启动。仍然找不到该命令。我做错了什么吗?
这是我的.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
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
解决了这个问题。
我在成功安装所有内容后遇到了同样的问题,我使用以下方法解决了它,创建了指向 yo、grunt、bower 的符号链接,如下所示:
为了哟
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/yo /usr/bin/yo
对于 Grunt
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/grunt /usr/bin/grunt
为了凉亭
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/bower /usr/bin/bower
这里在上面的命令中,公共路径/home/praveen/.npm-global/bin/
可能会根据您的系统文件夹结构而改变。
我已经安装了 node.js
并使用 npm-g_nosudo 脚本在我的 Yosemite 安装中设置了 npm
。当我然后 运行 npm install -g yo
时,我看到一堆内容在我的终端 window 中滚动,没有错误,它完成了。然后我输入 yo
和 OS X 告诉我它找不到命令。
Sullys-MacBook-Pro:~ Sully$ npm install -g yo
/Users/Sully/npm/bin/yo -> /Users/Sully/npm/lib/node_modules/yo/lib/cli.js
> yo@1.4.6 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!
yo@1.4.6 /Users/Sully/npm/lib/node_modules/yo
├── titleize@1.0.0
├── array-uniq@1.0.2
├── figures@1.3.5
├── user-home@1.1.1
├── opn@1.0.2
├── humanize-string@1.0.1 (decamelize@1.0.0)
├── sort-on@1.2.0 (dot-prop@2.0.0)
├── async@0.9.0
├── yeoman-character@1.0.1 (supports-color@1.3.1)
├── string-length@1.0.0 (strip-ansi@2.0.1)
├── cross-spawn@0.2.9 (lru-cache@2.6.2)
├── findup@0.1.5 (commander@2.1.0, colors@0.6.2)
├── chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
├── yosay@1.0.3 (ansi-regex@1.1.1, ansi-styles@2.0.1, strip-ansi@2.0.1, word-wrap@1.0.3, pad-component@0.0.1, taketalk@1.0.0, minimist@1.1.1)
├── root-check@1.0.0 (downgrade-root@1.1.0, sudo-block@1.2.0)
├── meow@3.1.0 (object-assign@2.0.0, camelcase-keys@1.0.0, minimist@1.1.1, indent-string@1.2.1)
├── package-json@1.1.0 (registry-url@3.0.3)
├── npm-keyword@1.1.1 (registry-url@3.0.3)
├── update-notifier@0.3.2 (is-npm@1.0.0, latest-version@1.0.0, semver-diff@2.0.0)
├── got@2.9.2 (lowercase-keys@1.0.0, timed-out@2.0.0, object-assign@2.0.0, is-stream@1.0.1, prepend-http@1.0.1, nested-error-stacks@1.0.0, statuses@1.2.1, infinity-agent@2.0.3, duplexify@3.3.0, read-all-stream@2.1.2)
├── fullname@1.1.0 (npmconf@2.1.1)
├── yeoman-environment@1.2.5 (log-symbols@1.0.2, escape-string-regexp@1.0.3, untildify@2.0.0, diff@1.4.0, text-table@0.2.0, debug@2.1.3, mem-fs@1.1.0, globby@1.2.0, grouped-queue@0.3.0)
├── configstore@0.3.2 (object-assign@2.0.0, xdg-basedir@1.0.1, osenv@0.1.0, graceful-fs@3.0.6, uuid@2.0.1, mkdirp@0.5.0, js-yaml@3.3.0)
├── insight@0.5.3 (object-assign@2.0.0, lodash.debounce@3.0.3, os-name@1.0.3, tough-cookie@0.12.1, request@2.55.0)
├── lodash@3.8.0
├── yeoman-doctor@1.3.2 (object-values@1.0.0, log-symbols@1.0.2, each-async@1.1.1, twig@0.7.2)
└── inquirer@0.8.3 (ansi-regex@1.1.1, cli-width@1.0.1, through@2.3.7, readline2@0.1.1, rx@2.5.2)
Sullys-MacBook-Pro:~ Sully$ yo
-bash: yo: command not found
我也尝试过使用 source .bash_profile
并重新启动。仍然找不到该命令。我做错了什么吗?
这是我的.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
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
解决了这个问题。
我在成功安装所有内容后遇到了同样的问题,我使用以下方法解决了它,创建了指向 yo、grunt、bower 的符号链接,如下所示:
为了哟
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/yo /usr/bin/yo
对于 Grunt
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/grunt /usr/bin/grunt
为了凉亭
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/bower /usr/bin/bower
这里在上面的命令中,公共路径/home/praveen/.npm-global/bin/
可能会根据您的系统文件夹结构而改变。