Microsoft 365 – SharePoint Online – SPFx – resolving error – ‘yo’ is not recognized as an internal or external command, operable program or batch file

fig : Microsoft 365 - SharePoint Online - creating SPFx component - Error while creating SPFx project - 'yo' is not recognized as an internal or external command, operable program or batch file
fig : Microsoft 365 - SharePoint Online - creating SPFx component - Error while creating SPFx project - 'yo' is not recognized as an internal or external command, operable program or batch file

Hi All,

Greetings for the day !!! Today new issue and solution 🙂

Background

  • After long time getting chance to work on SPFx component
  • Got an assignment (use case) to implement small, simple SPFx component to get some details from users in my organization and save to SharePoint list
  • I followed standard guidelines, followed very good article from Microsoft – Set up your SharePoint Framework development environment
  • I have installed Node.js, Gulp and Yeomen (yo)
  • I am ready to start my SPFx component
  • So first step is to create new project by using Yeomen SharePoint Generator as
yo @microsoft/sharepoint

  • And error occurred

Issue / Error

‘yo’ is not recognized as an internal or external command, operable program or batch file

fig : Microsoft 365 - SharePoint Online - creating SPFx component - Error while creating SPFx project - 'yo' is not recognized as an internal or external command, operable program or batch file
fig : Microsoft 365 – SharePoint Online – creating SPFx component – Error while creating SPFx project – ‘yo’ is not recognized as an internal or external command, operable program or batch file
  • Similar kind of error were there for ‘gulp‘ as well

C:\Users\prasham\Documents\SPFx>gulp
‘gulp’ is not recognized as an internal or external command, operable program or batch file.

Solution / Root cause

  • I am wondering even though I have successfully installed the respective tools
  • To make sure whether respective tools / components are there or not, I executed following command
npm list --global --depth=0

got the following output

fig : Microsoft 365 - SharePoint Online - creating SPFx component - It seems Yeomen, Gulp, SharePoint generator are installed successfully
fig : Microsoft 365 – SharePoint Online – creating SPFx component – It seems Yeomen, Gulp, SharePoint generator are installed successfully

  • From above image, output of command – npm list –global –depth=0, it seems respective tools / components are successfully installed 🙂
  • After bit googling, I found that it seems PATH is not set for NPM folder. Actually I thought PATH environment variable will be automatically updated for NPM folder
  • I executed PATH command for check as

C:\Users\prasham\Documents\SPFx>path
PATH=C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Program Files\PowerShell\7\;C:\Users\s1086350\AppData\Local\Microsoft\WindowsApps;




  • It seems PATH is not added for NPM folder
  • We need to add NPM folder to PATH
  • We have detailed article to Add / Edit / Delete environment variables for Windows 10 (since I have Windows 10 on my local laptop), please have a look – Windows 10 – Setting up environment variables – Adding / updating / deleting
  • Here, I wont go to detailed steps as already mentioned in above article
  • I’ll directly edit “PATH” environment variable as

fig : Windows 10 – Control Panel >> System and Security >> System >> Advanced system settings >> Environment Variables >> New / Edit / Delete
fig : Windows 10 – Control Panel >> System and Security >> System >> Advanced system settings >> Environment Variables >> New / Edit / Delete
  • By selecting “Path” environment variable and on click of “Edit…” button from “Environment Variables” dialog we will have “Edit environment variable” dialog will open as in below fig
  • On “Edit environment variable” dialog click on “New” button and add following line – Path for NPM folder

%appdata$\npm\;

fig : Windows 10 – Control Panel >> System and Security >> System >> Advanced system settings >> Environment Variables >> Updating PATH environment variable - Adding NPM folder path
fig : Windows 10 – Control Panel >> System and Security >> System >> Advanced system settings >> Environment Variables >> Updating PATH environment variable – Adding NPM folder path
  • Once we updated “PATH” for “NPM” folder, commands started working successfully 🙂

Thanks for reading !!! HAVE a FANTASTIC TIME AHEAD 🙂 LIFE IS BEAUTIFUL 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: