The Best Way to Install Node.js on a Windows PC
By: Mwiza Kumwenda
Tags: JavaScript, Programming, Software Development, Coding, Nodejs

The Best Way to Install Node.js on a Windows PC

How to install several versions of Node.js on a single PC

Photo by Caspar Camille Rubin on Unsplash

This post is a step-by-step guide on the recommended method of installing Node.js on a Windows PC using a Node Version Manager, popularly known as nvm.

Node.js is a popular, open-source, cross-platform JavaScript run time environment. It is widely used for both front-end and back-end software development.

If you are a front-end developer chances are high that you have worked with Node.js in one way or the other.

Background

The default and most common way of installing Node.js on a Windows PC is via a Node.js installer. Installing Node.js via this method allows you to only have a single installed version of Node.js at a time on your machine.

But what do you do if you are working on several projects where each project requires a different version of Node.js to run smoothly?

With a node version manager, you can install and switch between multiple versions of Node.js based on the needs of the different projects you are working on.

Advantages of using a node version manager

Some of the advantages of using a node version manager include:

Allows you to experiment with any version of Node.js without affecting other projects on your machine

You don’t need to uninstall older versions of node whenever you want to install a newer version

Ability to manage and have unique global npm packages 📦

Installing nvm-windows

For this guide, I will use the node version manager known as nvm-windows. I have chosen to use nvm-windows because it has good backing from Microsoft and Google.

Note: If you happen to have Node.js installed on your machine, uninstall it now to avoid conflicts and confusion. Also make sure to delete Node.js installation related files on this location “C:\Program Files

odejs” .

The latest installer for the nvm-windows can be found on the coreybutler GitHub account here.

Download the zipped folder nvm-setup.zip.

2. Extract the zip folder then

3. Double click the nvm-setup.exe from the folder you extracted. You will be presented with the installer screen as below.

4. Accept the terms and click next to start the installation

5. In the subsequent screen prompts just use the default settings to complete the installation.

Node version manager in action

Once the installation has completed successfully. Go ahead and open a new PowerShell terminal then run the command below to list currently installed versions of Node.js.

nvm ls

Since Node.js is not yet installed, you will get the output similar to the one below.

Show available packages for install

You can easily find out which packages of Node.js are available to install by running the command below.

nvm list available

Installing Node.js via nvm

To install the latest version of Node.js you can run the following command. Note: In addition, the node version manager will install the corresponding npm version for the Node.js being installed.

nvm install latest

We can install another Node.js version, for example, version 14.1.0 which was listed above using the following command.

nvm install 14.1.0

If you run the nvm ls command now, you will get a list of the installed Node.js versions.

Choose the version of Node.js you want to use

To select a specific version of Node.js that you want to use you can run the following command nvm use <version-number> . For example, to use version 14.0.1 you can run the following command.

nvm use 14.1.0

To change the version of Node.js at a project level. Simply run the node use command within the root of your project folder.

Conclusion

In this guide, I have gone through how to install and manage several versions of Node.js on the same machine using the node version manager. In addition, I have highlighted the advantages of using a node version manager for installing Node.js.

Nvm-windows also comes with several CLI commands for carrying out important tasks like installing or switching between the different versions of Node.js.