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 Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

Leave a Reply

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

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading