26

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)

user3789629
  • 357
  • 1
  • 5
  • 17
  • You are using cygwin shell, not cmd. Type exit and try in cmd. – Vinz243 Jul 01 '14 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." – user3789629 Jul 01 '14 at 14:19
  • 1
    When a program edits the PATH, the command prompt lust be restarted. Try it – Vinz243 Jul 01 '14 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 01 '14 at 18:59
  • Thanks guys, I think you made it! (Y) – user3789629 Jul 04 '14 at 15:39
  • @Vinz243 this was exactly the issue for me, many thanks! – 4imble Oct 20 '14 at 14:29

14 Answers14

43

Try adding this to your user path:

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

Then, restart the console.

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.

Ivan Zhang
  • 169
  • 2
  • 3
  • 1
    You could replace `C:\Users\` 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". – BlueStaggo Apr 23 '21 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
Rizier123
  • 58,877
  • 16
  • 101
  • 156
sree
  • 3,113
  • 2
  • 18
  • 13
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

SimplifyJS
  • 518
  • 1
  • 6
  • 12
1

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

1

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

gildniy
  • 3,528
  • 1
  • 33
  • 23
1

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 )

Ved Prakash
  • 487
  • 5
  • 9
0

Please try this command:

$ sudo npm install -g yo

Josh Harrison
  • 5,927
  • 1
  • 30
  • 44
0

I solve it by:

  1. Update the patch which normally located at C:\Users<myusername>\AppData\Roaming\npm
  2. Open CMD as administrator.
Hosein Djadidi
  • 198
  • 1
  • 3
  • 13
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
Bahu
  • 1,516
  • 2
  • 28
  • 49
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.

Santosh
  • 1,027
  • 13
  • 12
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

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
Zeb
  • 2,687
  • 7
  • 28
  • 36