Installing Yeoman - “Yo command not found”

匿名 (未验证) 提交于 2019-12-03 10:09:14

问题:

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.

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

This is my .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 

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 

回答1:

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



回答2:

I have faced the same problem after installing everything succesfully, I resolved it using the following method creating symbolic links to yo, grunt, bower like the following :

For Yo

praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/yo /usr/bin/yo 

For Grunt

praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/grunt /usr/bin/grunt 

For Bower

praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/bower /usr/bin/bower 

Here in the above commands the common path /home/praveen/.npm-global/bin/ may change according to your system folder structure.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!