Yeoman | yo command not found

浏览 : 553 次 Fri, 01 Apr 2022 06:10:07 GMT

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.

i've installed yeoman through:

$npm install -g yo

without any problems. I've also checked my $PATH under

$ 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. 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? Can I reset it in any way?

(OS: Windows 8.1 | Node v0.10.29)

  •  
    You are using cygwin shell, not cmd. Type exit and try in cmd. 
    – Vinz243
     Jul 1, 2014 at 13:08
  • 1
    Thanks, tried CMD now. Re-installed everything and tried 'yo' once again. This time with the result: "'yo' is not recognized as an internal or external command, operable program or batch file."   Jul 1, 2014 at 14:19
  • 1
    When a program edits the PATH, the command prompt lust be restarted. Try it 
    – Vinz243
     Jul 1, 2014 at 15:15
  • 8
    If the install was successful, then it's most likely a path issue. But you need to find where it's installed to verify that. Try running npm ls -g yo to see where it's installed. 
    – dylants
     Jul 1, 2014 at 18:59
  •  
    Thanks guys, I think you made it! (Y)   Jul 4, 2014 at 15:39

14 Answers

41

Try adding this to your user path:

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

Then, restart the console.

  • 1
    How/where do you add that to a user path? 
    – Niahc
     Sep 21, 2017 at 15:01
  • 4
    You should be able to just add %APPDATA%\npm. 
    – w4g3n3r
     Jun 6, 2018 at 1:11
 
7

Add this to PATH:

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

and be sure 2 things:

  • myusername is correct.
  • 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.

  • 1
    You could replace C:\Users\<myusername> with %USERPROFILE%, or, even better, replace %USERPROFILE%\AppData\Roaming with %APPDATA%. Add directories to PATH by searching from the Windows 10 start menu: "Edit environment variables for your account" or "Edit the system environment variables".   Apr 23, 2021 at 15:09
5

In windows run this in command prompt:

IF EXIST C:\Users\username\AppData\Roaming\npm SET PATH=%PATH%;C:\Users\username\AppData\Roaming\npm
  •  
    Doesn't get saved, when I close the CMD and check echo %path% it is gone. 
    – Maximc
     Apr 29, 2015 at 21:47
  •  
    Yes it will not be saved it will work in that "session" 
    – sree
     Oct 8, 2015 at 4:45 
 
3

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. I check the files manually and I found out that it doesn't not create Windows Command Script. 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

enter image description here

  •  
    Check the path C:\usr\local 
    – Santosh
     Jan 21, 2019 at 6:14
1

For me I added this:C:\usr\local to the PATH, and it worked like a charm!

0

Please try this command:

$ sudo npm install -g yo

  • 2
    his trying to install it in windows not in linux.   Nov 30, 2014 at 15:33
  •  
    This is useful for people who come to this question who need 'yo' installed on a Mac.   Aug 2, 2016 at 22:41
0

For me yo was installed in C:\Program Files (x86)\Git\local

After I added C:\Program Files (x86)\Git\local in Path, it worked

After you install yeoman, check the directory it is installed on and add that directory to path

0

I solve it by:

  1. Update the patch which normally located at C:\Users<myusername>\AppData\Roaming\npm
  2. Open CMD as administrator.
0

Try these (Worked for me in 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
0

i was getting yo: command not found after successfully installing yeoman on my Windows machine. i was able to fix this by replacing "yo" with the following /c/Users/daclar.CLARKE-BOOK/AppData/Roaming/npm/yo

i got that Path from finding Yeman files on my machine and copying the file path

this allowed me to continue with my Yo commands form Git Bash so instead of doing...

 $ yo hubot --adapter="slack"

i did..

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

You have to add the path where yo is installed. You can check that by giving the following command.

npm config get prefix. you should get a location. Navigate to the location and see if yo is installed at the location.

for me, the location was C:\usr\local. So I added the same to environment variables and done.

0

In Windows, just install the Yeoman Generator globally by,

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

0

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 )

0

We need to remove nodejs cache by performing the following steps:

  1. Uninstall Nodejs
  2. Please try to delete npm & npm-cache folders from C:\Users\myusername\AppData\Roaming
  3. Remove all environment variable related node if any
  4. Re-install node js
  5. then install yo by npm install -g yo
  6. If still not recongnized in cmd , then set path variable: C:\Users\myusername\AppData\Roaming\npm
 
https://stackoverflow.com/questions/24511032/yeoman-yo-command-not-found