Sharepoint - SPFx: Yo is not recognized as an internal or external command

  1. install the latest version of node
  2. install the latest version of npm: npm i -g npm@next
  3. run the following in your cmd window or commander window:

    call npm uninstall -g chalk
    call npm uninstall -g loadash
    call npm uninstall -g tar-fs
    call npm uninstall -g update-notifier
    call npm uninstall -g yeoman-generator
    call npm uninstall -g yosay
    call npm uninstall -g yo
    call npm uninstall -g gulp
    call npm uninstall -g @microsoft/generator-sharepoint
    
    call npm install -g chalk
    call npm install -g loadash
    call npm install -g tar-fs
    call npm install -g update-notifier
    call npm install -g yeoman-generator
    call npm install -g yosay
    
    call npm install -g yo
    call npm install -g gulp
    
    call npm install -g @microsoft/generator-sharepoint
    

these commands set will install some missing modules that were not installed when you followed the doc on github(and no you weren't stupid)

once you run the above, you can run the yo command to create your helloworld

$ yo @microsoft/generator-sharepoint

and you will have your hello world app.... (what a way to go for a Hello World)

PS: you don't need commander, the CMD will do just fine, just make sure the node path is included in the %PATH% variable and can be found by gulp.

:)


Most likely cause is the NPM folder is missing from the PATH declaration, so it can not find the commands installed in the NPM folder

For Windows:

Check if everything is correctly installed

Execute in a command prompt:

dir %appdata%\npm\*.cmd /b

This should list the available commands:

Execute the Yeoman SharePoint Generator

%appdata%\npm\yo @microsoft/sharepoint

add NPM folder to %PATH%

If you add the npm folder to the PATH you do not have to reference the full path all the time

  • Go to My Computer + Right Click "Properties"
  • Advanced System Settings (On the left)
  • Click on Environment Variables
  • Click on Edit
  • Path Add "%appdata%\npm\;" to the end

    * Click ok and reopen Cmd(r)

Only addition of environment variable "path" will do in case of a new user logged in to the machine but using the VS installed by other user. Tested and verified in OS - Windows 10. VS -2015.


Sometimes you need to refresh the PATH. I just open a new command window, which seems to be the simplest way of doing this.

Tags: