Use multiple Node.js versions on your computer (and develop a SPFx webpart)

2021-01-23 | Toni Pohl

As developer, it often makes sense to have multiple versions of a framework installed on a single computer. For example, when developing SPFx applications with Node,js v10.x and developing web applications using Angular and Node.js v14.x you need both versions. Thankfully, with Node Version Manager, we can.

To dive directly into the commonly used Node.js versions:

Install nvm and Node.js

We follow the steps here to install these Node.js frameworks on our machine. Alternatively, there´s a good description at Set up your Node.js development environment directly on Windows.

That´s the basic installation of Node.js and npm.

Install the SPFx development tools once

To install the required tools yo with the sharepoint generator and gulp and for SharePoint development, we follow the steps at Set up your SharePoint Framework development environment. Here are the commands to run in a PowerShell console: First, we switch to Node.js v10, confirm, (check the current version), and install the tools with npm.

nvm use 10.23.0

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


Create a new SPFx webpart

To create a new SPFx app, follow the steps described at Build your first SharePoint client-side web part (Hello World part 1). In a new directory, we run

yo @microsoft/sharepoint


We need to trust the development self-signed SSL certificate as described at Trusting the self-signed developer certificate here. Then, we can open the workbench with SSL.

gulp trust-dev-cert


We can open Visual Studio code here: code .

Run the SPFx webpart

The generated solution includes the sample app that can now be modified.


When done, let´s open the default browser with the gulp webserver:

gulp serve

…opens the SPFx workbench, in our sample at https://localhost:4321/temp/workbench.html. Here, we can add the webpart to the workbench page.


Tip: When gulp serve is running, you can open your M365 tenant´s SPO site and use the custom webpart with the data from SharePoint, too: https://<tenant><sitename>/_layouts/15/workbench.aspx

Deploy the SPFx solution

To build the ready-to-use solution, we can run

gulp bundle --ship

to build the package for the correct folder and

gulp package-solution --ship

to create the \sharepoint\solution\<project>.sppkg file that can be uploaded to the SharePoint App catalog.

Develop the solution

We can follow the next steps to develop the app described here:

Switch as required with nvm

The Node Version Manager really helps to work with multiple versions of Node.js for different purposes on the same machine. I hope this tip helps developers for a productive development environment!

Categories: Developer, English, Microsoft, Open Source, SharePoint, Tools