How to run beta versions of SPFx along with the previous versions
Surajit Mukherjee, MBA
Transformational Technical Leader| Providing Automation & Digital Workplace solutions to the clients | Driving Strategic, Agile Solutions in Complex Business Environments
For my project, I needed to use previous versions of the SPFx but I didn't want to miss out on trying the Adaptive Card Extension (ACE) for Viva Connections dashboard. The solution was to run the beta version of SPFx locally along with yeoman generator. There are some excellent articles written on this topic by Waldek Mastykarz (Why you should consider installing the SharePoint Framework Yeoman generator locally) and Vardhaman Deshpande? (Run different versions of the SPFx Yeoman generator in different folders).
The idea is to run specific versions of SPFx and Yeoman generator using npx which is a node package that helps to run node modules from command line without installing them.
Although I managed to create the project with the beta versions of SPFx and Yeoman generator, I was still having issues with the gulp version. My gulp-cli version (global) was 3.9.1 but the local gulp version required was 4.0.2. I could not build the project after creating the project due to the gulp version mismatch.
To resolve the issue, I ran the following command to create the project:
npx -p yo -p gulp -p @microsoft/generator-sharepoint@next -- yo @microsoft/sharepoint
Using the?-p (package) flag, I loaded the latest versions yeoman generator (yo), gulp and beta version SPFx generator (microsoft/generator-sharepoint@next). Then I created the project by running -- yo @microsoft/sharepoint
To build the project and test it in the local workbench, I ran the following command:
npx gulp serve
This helps to use the latest gulp package locally without installing the package.