Install any of the below code editors.
Install Yeoman and gulp
Run the below command.
Install Yeoman SharePoint Generator
Run the below command.
- npm install -g @microsoft/generator-sharepoint
Develop SharePoint Framework Web Part
Open the command prompt. Create a directory for SPFx solution.
- md spfx-onprem-hello-world
Navigate to the above-created directory.
- cd spfx-onprem-hello-world
Run Yeoman SharePoint Generator to create the solution.
Yeoman generator will present you with the wizard by asking questions about the solution to be created.
Solution Name: Hit Enter to have a default name (spfx-onprem-hello-world in this case) or type in any other name for your solution.
Selected choice: Hit Enter
Target for component: Here, we can select the target environment where we are planning to deploy the client webpart, i.e., SharePoint Online only (latest) / SharePoint 2016 onwards, including 2019 and SharePoint Online / SharePoint 2019 onwards, including SharePoint Online.
Selected choice: SharePoint 2016 onwards, including 2019 and SharePoint Online
Place of files: We may choose to use the same folder or create a subfolder for our solution.
Selected choice: Same folder
Deployment option: Selecting Y will allow the app to deployed instantly to all sites and will be accessible everywhere.
Selected choice: N (install on each site explicitly)
Type of client-side component to create: We can choose to create a client-side webpart.
Selected choice: WebPart
Unless it is SharePoint Online, we do not have an option to create SharePoint extensions in SharePoint OnPremise 2016 version using SPFx generator.
Web part name: Hit Enter to select the default name or type in any other name.
Selected choice: OnPremHelloWorld
Web part description: Hit Enter to select the default description or type in any other value.
Selected choice: SPFx on SharePoint 2016
Framework to use: Select any JavaScript framework to develop the component. Available choices are No JavaScript Framework, React, and Knockout.
Selected choice: React
Yeoman generator will perform scaffolding process to generate the solution. The scaffolding process will take a significant amount of time.
Once the scaffolding process is completed, lock down the version of project dependencies by running the below command.
In the command prompt, type the below command to open the solution in code editor of your choice.
Troubleshooting
Below are a few common issues and resolutions.
Issue# 1: Workbench does not load
Although you have everything installed and correctly set up, you might face the below issues on running “gulp serve”.
Internet Explorer
Google Chrome
Resolution
In the command prompt, run the below command to resolve the issue.
Issue# 2 - “gulp serve” is not running
In some cases, the SharePoint workbench (https://[tenant].sharepoint.com/_layouts/15/workbench.aspx) shows below error although “gulp serve” is running.
Resolution
Open this URL in the next tab of the browser. Accept the warning message.
https://localhost:4321/temp/manifests.js
Summary
For the future compatibility of the solution, it is recommended to start using SharePoint Framework based development in SharePoint OnPremise. Also, duly note that SPFx solutions created for SharePoint Online might not work for SharePoint OnPremise.