8-Week Microsoft Teams AppDev Accelerator Program
Limited seats available! - Start date: Wednesday, April 16, 2025
Join Today & Save $1,000
articles

Multiple Node.js Installs with NVM and Global Packages

Explore the power of the Node Version Manager (NVM) in managing multiple Node.js installs for diverse SharePoint and Teams Toolkit projects.

Multiple Node.js Installs with NVM and Global Packages
by Andrew Connell

Last updated March 14, 2025
3 minutes read

Share this

Focus Mode

  • How NVM works
  • NVM makes all Node.js installs 100% isolated from each other
  • NVM for Mac OS simplifies new Node.js version installs
  • Feedback & questions

Different SharePoint Framework (SPFx) and Microsoft Teams Toolkit (TTK) project types support various versions of Node.js. For instance, different SPFx versions require specific Node.js versions. This means you need the right version of Node.js installed on your machine to run and compile these projects.

The challenge arises when you need multiple versions of Node.js on your machine. By default, Node.js doesn’t support this; it allows only one installation. However, using the popular tool Node Version Manager (NVM), available for both Mac OS and Windows, you can install multiple Node.js versions on your computer. This tool also simplifies switching between versions on the fly.

How NVM works

When you switch to different versions of Node.js, NVM updates the PATH environment variable on your system. This change points to the folder containing the version of Node.js you wish to use.

The PATH environment variable, found on both Mac OS and Windows, serves a very important role. It specifies the directories to search when finding a command, meaning directories in the PATH allow you to run executables from those folders anywhere in your environment. In this case, you can execute the Node process from any location in your environment.

NVM makes all Node.js installs 100% isolated from each other

It’s important to note that each version of Node.js you install is completely isolated from the others. This isolation applies not only to the Node.js runtime executable, but also to the global package registry for each Node.js version.

For instance, if I have Node.js v16.20.2 installed with all necessary tools for the SPFx in the global registry - like Yeoman (yo), the Yeoman generator for SPFx (@microsoft/generator-sharepoint), and the Gulp CLI (gulp-cli) - these tools are only available for that specific Node.js version.

> node -v
v16.20.2

// show contents
> npm list -g
/Users/ac/.nvm/versions/node/v16.20.2/lib
├── @microsoft/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

If I install a new version of Node.js v18.20.2 using NVM, the global registry of that installed version won’t contain the three packages that I need.

> node -v
v18.20.2
// show contents
> npm list -g
/Users/ac/.nvm/versions/node/v18.20.2/lib
├── [email protected]
└── [email protected]

I’ll need to reinstall those three packages into the same registry.

NVM for Mac OS simplifies new Node.js version installs

One way to simplify the process is by using the Mac OS version of NVM. It contains the --reinstall-packages-from argument, which automatically installs all the same packages from another installed Node.js version to your new one. This argument can be used with the nvm install command.

nvm install v18.20.1 --reinstall-packages-from=16.20.2

This will enable NVM to automate package handling after installing a new version of Node.js. It will automatically locate all packages installed in other versions of Node.js package registry and install them into the new version right away. This greatly simplifies and accelerates the process of installing a new version of Node.js.

Andrew Connell, Microsoft MVP, Full-Stack Developer & Chief Course Artisan - Voitanos LLC.
author
Andrew Connell

Microsoft MVP, Full-Stack Developer & Chief Course Artisan - Voitanos LLC.

Andrew Connell is a full stack developer who focuses on Microsoft Azure & Microsoft 365. He’s a 20+ year recipient of Microsoft’s MVP award and has helped thousands of developers through the various courses he’s authored & taught. Whether it’s an introduction to the entire ecosystem, or a deep dive into a specific software, his resources, tools, and support help web developers become experts in the Microsoft 365 ecosystem, so they can become irreplaceable in their organization.

Feedback & Questions

newsletter

Join 10,000+ developers for news & insights

No clickbait · 100% free · Unsubscribe anytime.

Subscribe to Andrew's newsletter for insights & stay on top of the latest news in the Microsoft 365 Space!
blurry dot in brand primary color
found this article helpful?

You'll love these!

Multiple Node.js Versions with Node Version Manager (NVM)

Multiple Node.js Versions with Node Version Manager (NVM)

April 26, 2017

Read now

Try SharePoint Framework Preview Releases with NVM

Try SharePoint Framework Preview Releases with NVM

April 20, 2021

Read now

How to set up SPFx development environments for multiple SharePoint Server deployments

How to set up SPFx development environments for multiple SharePoint Server deployments

January 25, 2022

Read now

bi-weekly newsletter

Join 10,000+ Microsoft 365 full-stack web developers for news, insights & resources. 100% free.

Subscribe to Andrew's newsletter for insights & stay on top of the latest news in the Microsoft 365 ecosystem!

No clickbait · 100% free · Unsubscribe anytime.

Subscribe to Andrew's newsletter for insights & stay on top of the latest news in the Microsoft 365 Space!