Set up your SharePoint Framework development environment

You can use any text editor to build SharePoint Framework solutions. You can use a macOS, Windows, or Linux environment as well.

Note

Before following the steps in this article, be sure to Set up your Microsoft 365 tenant.

You can also follow these steps by watching this video on the SharePoint PnP YouTube Channel:

Important

The following steps assume you're building solutions for SharePoint Online using the latest version of the SharePoint Framework. If you're building solutions for SharePoint Server 2019 or SharePoint Server 2016, refer to the additional documentation referenced in the See also section below.

Install Node.js

Install the latest version of Node.js LTS v14.

This version is the currently recommended version of Node.js to use with the SharePoint Framework (unless otherwise specified below).

Important

Node.js is frequently updated and available on multiple platforms including macOS, Windows, and Linux. Because the exact download links change frequently, they aren't linked to from this page. Instead, use the details below to determine which installer to download for your platform.

Be aware that Node.js maintains two different releases at all times: LTS & Current version. The SharePoint Framework is only supported on LTS versions. For more information about Node.js's Long Term Support (LTS) releases, see: Node.js > Releases.

Tip

The Node.js website always recommends the latest installer for both the LTS & Current releases. To download specific versions of Node.js versions, use the Node.js > Downloads > Previous Releases page.

  • Windows users can use the *.msi installers for x86 or x64 depending on your Windows installation. There are usually only two available *.msi files with names similar to node-v{version-number}-x[86|64].msi.
  • macOS users can use the *.pkg installer that's usually is named node-v{version-number}.pkg.

You can check if you already have Node.js already installed, including installed version, by running the following command:

node -v

The SharePoint Framework v1.12.1 is supported on the following Node.js versions:

  • Node.js v10.13.0+ (Dubnium)
  • Node.js v12.13.0+ (Erbium)
  • Node.js v14.15.0+ (Fermium)

Caution

If you're building SharePoint Framework components for SharePoint on-prem deployments, refer to the additional pages listed in the See also section for more information.

Install a code editor

You can use any code editor or IDE that supports client-side development to build your web part, such as:

The steps and examples in this documentation use Visual Studio Code, but you can use any editor of your choice.

Install development toolchain prerequisites

The SharePoint Framework development and build toolchain leverages various popular open-source tools. While most dependencies are included in each project, you need to install a few dependencies globally on your workstation.

Tip

You can install all three of the following tools in a single line:

npm install gulp yo @microsoft/generator-sharepoint --global

Install Gulp

Gulp is a JavaScript-based task runner used to automate repetitive tasks. The SharePoint Framework build toolchain uses Gulp tasks to build projects, create JavaScript bundles, and the resulting packages used to deploy solutions.

Enter the following command to install Gulp:

npm install gulp --global

Important

If you're using Node.js v12+ or higher, you must use Gulp v4+. If you're using a version of Node.js lower than v12, you must use Gulp v3. For more information, see: SharePoint Framework v1.12.1 release notes | Gulp versions & Node.js v12+

Install Yeoman

Yeoman helps you kick-start new projects, and prescribes best practices and tools to help you stay productive. SharePoint client-side development tools include a Yeoman generator for creating new web parts. The generator provides common build tools, common boilerplate code, and a common playground website to host web parts for testing.

Enter the following command to install Yeoman:

npm install yo --global

Install Yeoman SharePoint generator

The Yeoman SharePoint web part generator helps you quickly create a SharePoint client-side solution project with the right toolchain and project structure.

To install the SharePoint Framework Yeoman generator globally, enter the following command:

npm install @microsoft/generator-sharepoint --global

For more information about the Yeoman SharePoint generator, see Scaffold projects by using Yeoman SharePoint generator.

Install a modern web browser

You should be using a modern web browser like Microsoft Edge, Google Chrome, or Firefox as the development browser. Local workbench doesn't support usage of Internet Explorer 11.

Trusting the self-signed developer certificate

The SharePoint Framework's local webserver, used when testing your custom solutions from your development environment, uses HTTPS by default. This is implemented using a development self-signed SSL certificate. Self-signed SSL certificates are not trusted by your developer environment. You must first configure your development environment to trust the certificate.

A utility task is included in every SharePoint Framework project in the form of a gulp task. You can elect to do this now, or wait until you create your first project as covered in the Build your first SharePoint client-side web part (Hello World part 1) tutorial.

Once a project has been created with the Yeoman generator for the SharePoint Framework, execute the following command from within the root folder of the project.

gulp trust-dev-cert

Note

This assumes you have installed all dependencies with npm install after creating the project. This step will install all gulp tasks as part of a project.

Optional tools

Following are some tools that might come in handy as well:

Next steps

You're now ready to build your first client-side web part!

SPFx & SharePoint Server (on-prem)

The SPFx is available on SharePoint Online (SPO), SharePoint Server 2019, & SharePoint Server 2016. The configuration instructions on this page assume you're creating solutions using the latest version of the SPFx for SharePoint Online.

SharePoint Online contains all versions of the SPFx, including all previous and the latest version. Each SPFx solution contains information to tell SPO which SPFx runtime it depends.

If you're building solutions for a SharePoint Server on-prem deployment, review to the See also section for details on specific SharePoint versions. Each SharePoint on-prem only supports a specific version of SPFx. This can introduce complicated development environment configurations if you're creating different solutions for different SharePoint deployments.

Depending on your scenario, you may need to maintain different development environments. Developers have used the following approaches to address these challenges:

  • virtual machines

  • Docker

  • Node Version Manager (NVM)

  • SharePoint Server 2016 uses the SharePoint Framework (SPFx) v1.1.

  • SharePoint Server 2019 uses the SharePoint Framework (SPFx) v1.4.1.

Troubleshooting

Check the version of globally installed packages

To get a list of all globally installed packages, run the following command:

npm list --global --depth=0️

Unable to Trust the Self-signed Development Certificate

If you're having trouble trusting your self-signed certificate when you run gulp trust-dev-cert & you've verified that the correct versions of all dependencies are installed, one solution we usually see resolve the issue is to uninstall all globally installed packages, uninstall Node.js, reboot & start again.

In some cases, executing the command gulp trust-dev-cert, doesn't have the wanted effect of trusting the self-signed development certificate on your machine. In rare cases such as these, you may need to delete a hidden folder that's generated in your profile folder. Locate & delete the folder /.gcb-serve-data and then try to trust the self-signed development certificate again.

Unable to Install Packages with NPM - Corporate Proxies

If your development environment is behind a corporate proxy, you need to configure NPM to use that proxy. Refer to the npm-config documents on how to configure your development environment behind a corporate proxy... specifically the proxy & http-proxy settings. More information: How to setup Node.js and Npm behind a corporate web proxy

See also