简体   繁体   English

Yeoman | 找不到你的命令

[英]Yeoman | yo command not found

Saw that there were some similar questions as this one but didn't find the answers satisfying enough or applicable to my problem so thought I'd thought I'd ask one more time. 看到有一些类似的问题,但没有找到足够的答案或适用于我的问题所以我以为我会再问一次。

i'm having trouble with the "$ yo" command and that my cmd keeps telling me that the command is not found. 我遇到了“$ yo”命令的问题,我的cmd一直告诉我找不到该命令。

i've installed yeoman through: 我通过以下方式安装了自己:

$npm install -g yo

without any problems. 没有任何问题。 I've also checked my $PATH under 我还检查了我的$ PATH

$ echo $PATH
/c/Users/Anton/bin:.:/usr/local/bin:/mingw/bin:/bin:.:/c/Program Files (x86)/Java/jre7/bin:/usr/cmd:/usr/bin:/c/Program Files (x86)/nodejs/:/c/Users/Anton/AppData/Roaming/npm

and confirmed that yo is installed together with other node modules. 并确认yo与其他节点模块一起安装。 I'm able to call other commands such as: 我可以调用其他命令,例如:

$ bower

Usage:

bower <command> [<ar.....

and

$ yeoman
==========================================================================
We're constantly looking for ways to make yeoman better!
May we anonymously report .....

with out any problems. 没有任何问题。 While yo results in failure 虽然哟导致失败

$ yo
sh.exe": yo: command not found

Does anyone have any suggestions of what's wrong? 有没有人有什么错误的建议? I've read that ther might be something wrong with the $PATH? 我已经读过$ PATH可能有问题吗? Can I reset it in any way? 我可以以任何方式重置它吗?

(OS: Windows 8.1 | Node v0.10.29) (操作系统:Windows 8.1 |节点v0.10.29)

Try adding this to your user path: 尝试将此添加到您的用户路径:

C:\Users\myusername\AppData\Roaming\npm

Then, restart the console. 然后,重新启动控制台。

Add this to PATH: 将此添加到PATH:

C:\Users\<myusername>\AppData\Roaming\npm

and be sure 2 things: 并确保2件事:

  • myusername is correct. myusername是正确的。
  • restart console and test by : 重启控制台并测试:

     echo $PATH 

i just fixed the same issue on my windows, $PATH should be updated on system PATH to avoid user PATH to override. 我刚刚在我的Windows上修复了同样的问题,应该在系统PATH上更新$ PATH以避免用户PATH覆盖。

在Windows中,在命令提示符下运行:

IF EXIST C:\Users\username\AppData\Roaming\npm SET PATH=%PATH%;C:\Users\username\AppData\Roaming\npm

I also tried to add C:\\Users\\myusername\\AppData\\Roaming\\npm, uninstalling, reinstalling yo globally,and restarted console but still prints out yo:command not found . 我还尝试添加C:\\ Users \\ myusername \\ AppData \\ Roaming \\ npm,卸载,全局重新安装yo,然后重新启动控制台,但仍然打印出yo:command not found I check the files manually and I found out that it doesn't not create Windows Command Script. 我手动检查文件,我发现它不会创建Windows命令脚本。 I'm not sure if this related to that but maybe it may help to find solution for this issue. 我不确定这是否与此相关,但可能有助于找到解决此问题的方法。 My OS: Windows 8.1 我的操作系统:Windows 8.1

在此输入图像描述

对我来说,我添加了这个: C:\\usr\\localPATH ,它就像一个魅力!

Please try this command: 请尝试以下命令:

$ sudo npm install -g yo $ sudo npm install -g哟

For me yo was installed in C:\\Program Files (x86)\\Git\\local 对我来说,你安装在C:\\Program Files (x86)\\Git\\local

After I added C:\\Program Files (x86)\\Git\\local in Path, it worked 在Path中添加C:\\Program Files (x86)\\Git\\local之后,它运行了

After you install yeoman, check the directory it is installed on and add that directory to path 安装yeoman后,检查其安装目录并将该目录添加到路径

I solve it by: 我通过以下方式解决

  1. Update the patch which normally located at C:\\Users<myusername>\\AppData\\Roaming\\npm 更新通常位于C:\\Users<myusername>\\AppData\\Roaming\\npm的补丁
  2. Open CMD as administrator. 以管理员身份打开CMD。

Try these (Worked for me in Mac) 试试这些(在Mac上为我工作)

1.  export PATH="$PATH":~/.node/bin

2.  npm config set prefix ~/npm

3.  echo "export NODE_PATH=$NODE_PATH:/home/$USERNAME/npm/lib/node_modules" >> ~/.bashrc && source ~/.bashrc

i was getting yo: command not found after successfully installing yeoman on my Windows machine. 我得到了哟:在我的Windows机器上成功安装yeoman后找不到命令。 i was able to fix this by replacing "yo" with the following /c/Users/daclar.CLARKE-BOOK/AppData/Roaming/npm/yo 我能够通过用以下/c/Users/daclar.CLARKE-BOOK/AppData/Roaming/npm/yo替换“yo”来解决这个问题。

i got that Path from finding Yeman files on my machine and copying the file path 我有机会在我的机器上找到Yeman文件并复制文件路径

this allowed me to continue with my Yo commands form Git Bash so instead of doing... 这让我继续使用Git Bash的Yo命令,而不是......

 $ yo hubot --adapter="slack"

i did.. 我做了..

 $ /c/Users/daclar.CLARKE-BOOK/AppData/Roaming/npm/yo hubot --adapter="slack"

You have to add the path where yo is installed. 您必须添加安装yo的路径。 You can check that by giving the following command. 您可以通过提供以下命令来检查它。

npm config get prefix . npm config get prefix you should get a location. 你应该得到一个位置。 Navigate to the location and see if yo is installed at the location. 导航到该位置,看看是否在该位置安装了yo。

for me, the location was C:\\usr\\local . 对我来说,位置是C:\\usr\\local So I added the same to environment variables and done. 所以我将相同的内容添加到环境变量并完成。

In Windows, just install the Yeoman Generator globally by, 在Windows中,只需在全球安装Yeoman Generator,

One Line Install npm install -g yo

and then add the following path in you system variables, 然后在系统变量中添加以下路径,

C:\\Users\\myusername\\AppData\\Roaming\\npm

You can refer more on https://github.com/keystonejs/generator-keystone 您可以在https://github.com/keystonejs/generator-keystone上查阅更多内容

Run the following command : 运行以下命令:

C:\Windows\System32\cmd.exe /k "C:\Program Files\nodejs\nodevars.bat"

This will start node command prompt. 这将启动节点命令提示符。 Please note that SPFx is currently supported at node version 8 ( https://nodejs.org/dist/v8.11.4 ) 请注意,节点版本8( https://nodejs.org/dist/v8.11.4 )目前支持SPFx

We need to remove nodejs cache by performing the following steps: 我们需要通过执行以下步骤来删除nodejs缓存:

  1. Uninstall Nodejs 卸载Nodejs
  2. Please try to delete npm & npm-cache folders from C:\\Users\\myusername\\AppData\\Roaming 请尝试从C:\\Users\\myusername\\AppData\\Roaming删除npmnpm-cache文件夹
  3. Remove all environment variable related node if any 删除所有环境变量相关节点(如果有)
  4. Re-install node js 重新安装节点js
  5. then install yo by npm install -g yo 然后通过npm install -g yo
  6. If still not recongnized in cmd , then set path variable: C:\\Users\\myusername\\AppData\\Roaming\\npm 如果仍然没有在cmd中识别,则设置路径变量: C:\\Users\\myusername\\AppData\\Roaming\\npm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM