Node.js (nodejs) and npm Installation on Windows

Published:

|

Updated:

In this beginner's tutorial, we'll learn how to install Node.js and npm on Windows, their brief introduction and benefits, and why we may need them in our development environment.

Furthermore, we'll also learn about NVM, which allows us to manage different Node versions.

Let's get started.

Node.js (nodejs) and npm Installation on Windows

What Is Node.js® (nodejs)?

Node.js (also known as nodejs or simply Node) is a cross-platform JavaScript runtime environment that allows the usage and execution of JavaScript outside a web browser. It runs on Google's V8 JavaScript engine, an Open-Source JS engine.

It can be used for creating many applications and other stuff. For example, one of the popular Static Site Generators, Eleventy (or 11ty), is based on and uses Node.js.

Node.js Benefits

While you may think that Node might be related to just application or web development, it's not necessarily the case. You can use it for many other purposes.

For instance, you could create a Node.js application to automate the task of processing images to optimize and minify them using a JavaScript-based tool like Gulp.

Often, it's used to create Node.js servers to serve websites (either locally or online).

Different Node.js Versions or Phases

It's important to understand the different Node.js versions or phases and which one you should use.

There are two versions: the LTS (Long Term Support - stable release) and the Current version (with the latest features in development).

Another phase, the Maintenance phase, contains critical bug fixes and security updates.

Long Term Support (LTS) Version

The LTS version contains many new features and bug fixes. It is stable and recommended for most users.

The latest LTS version is 16.17.1, which includes npm version 8.15.0 (as of writing this article).

Current Version

The Current version contains most of the latest features, some of which might be under development, useful for developers looking to experience cutting-edge technologies. Thus, it's not advised for beginners and new users to use it when getting started with it.

The latest Current version is 18.10.0, which includes npm version 8.19.2 (as of writing this article).

You may read about different phases in detail on the Node.js GitHub repository.

Node.js Frameworks

There are many Node.js frameworks available should you prefer to use one. Some popular ones are Express.js, Next.js, and Meteor (MeteorJS).

These frameworks allow you to speed up the coding process by taking care of the many low-level programming challenges and/or repetitive work.

What Is npm?

npm stands for Node Package Manager. As you may have imagined, it is a tool that allows us to easily manage Node.js packages.

npm Benefits

Apart from managing Node.js packages, npm helps us identify which packages have vulnerabilities or issues and automatically offers to fix the possible ones without us having to do the manual work.

What Is NVM?

NVM stands for Node Version Manager, which allows us to manage different Node.js versions. This tool is particularly helpful if you want to run multiple versions of Node.

It has several versions available depending on the Operating System and platform; however, we'll be using Corey Butler's version for Windows. So, if you're on Mac/Linux, you may want to use a different version.

NVM Benefits

With this tool, you can easily switch between multiple versions of Node.js. Unless you have a specific reason to use multiple versions, you would usually stick with a single version.

Getting Started

Unless you're installing Node.js for the first time, you should ensure that it's not already installed on your PC. Otherwise, the installation will overwrite it.

If it's already installed on your PC, consider uninstalling it first. The steps to uninstall Node.js are mentioned below.

Note

It's important to note that when you use and run the terminal, whether you're using Windows Command Prompt, Windows PowerShell, or an integrated terminal of an IDE like VS Code, you should always run as administrator to prevent any admin privileges issues in the future.

This is because these tools try to access some privileged actions and locations on the system.

Checking the Currently Installed Node.js Versions Using Node Version Manager

If you're using NVM, you can check if you already have Node.js installed on your PC or not by using the following command.

nvm list

The terminal should output the list of Node.js installations and their versions if it finds any on your PC.

Using the nvm list command to check the currently available installed versions of Node.js.
Using the nvm list command to check the currently available installed versions of Node.js.
View Original Image Size

Uninstall Existing Node.js

Depending on how you installed Node previously, the method to uninstall it varies on the installation type. Below, I've shown two general methods to uninstall it.

Uninstall via the Version Manager

Follow these steps if you're using a version manager.

Launch the terminal and type the following.

nvm uninstall 16.15.1

Here, I'm uninstalling the 16.15.1 version from my PC.

Using the nvm uninstall command to uninstall Node.js version 16.15.1.
Using the nvm uninstall command to uninstall Node.js version 16.15.1.
View Original Image Size

To confirm that Node.js was uninstalled successfully, type the following.

nvm list

Using the nvm list command to confirm the Node.js uninstall.
Using the nvm list command to confirm the Node.js uninstall.
View Original Image Size

As you can see above in the screenshot, it says that "No installations recognized.", which means that there are currently no Node.js installations found on your PC.

Uninstall via the Windows Apps & features Settings

Follow these steps to uninstall Node.js using the Windows Apps & features settings.

Note

Depending on your Windows version, this process might differ slightly, but the general concept is the same.

I've mentioned Windows 11 steps below. Consider searching on the internet for your specific Windows version if you're using Windows 10 or older versions.

Search for and open Apps & features via the Start menu (Windows key) or from the Settings app (Windows + I keyboard shortcut) > Apps > Apps & features.

Launching Apps & features via the Start menu.
Launching Apps & features via the Start menu.
View Original Image Size

Find Node.js in the apps list and uninstall it.

Uninstalling Node.js from Apps & features settings.
Uninstalling Node.js from Apps & features settings.
View Original Image Size

Node.js Installation

There are two ways to get Node.js; one is using a version manager (recommended), and the other is directly from its website. I'll show you both ways.

Let's see how to download it with a version manager first.

Install Node.js on Windows with Node Version Manager (Recommended)

Step 1 - Download NVM

Go to Corey Butler's GitHub repository and look for the Releases section on the right sidebar. You should see a version (1.1.9 as of writing this article) listed there.

nvm-windows GitHub repository.
nvm-windows GitHub repository.
View Original Image Size

Either click on the Releases or the version link. This should take you to the Releases page, where you can download the tool.

Scroll down until you see the Assets heading, which should have several different files listed for download. The one we'll use in our tutorial is the nvm-setup.exe file, so go ahead and download it.

Downloading nvm-windows from GitHub.
Downloading nvm-windows from GitHub.
View Original Image Size

Step 2 - Install NVM

Once downloaded, run the installer and follow the setup instructions to complete its installation.

You'll be asked to agree with the license agreement to proceed.

NVM setup: license agreement.
NVM setup: license agreement.
View Original Image Size

After agreeing to the license, you'll be asked to decide where you want to install it. The default location is fine, so there is no need to change it.

NVM setup: choosing the destination location for NVM.
NVM setup: choosing the destination location for NVM.
View Original Image Size

On the next screen, you'll be asked to choose the Node.js Symlink location. Again, you may install it in the default provided location.

NVM setup: choosing the Node.js Symlink location.
NVM setup: choosing the Node.js Symlink location.
View Original Image Size

Once everything is ready to install, you'll be shown the last confirmation screen. Click the Install button to continue.

NVM setup: ready to install.
NVM setup: ready to install.
View Original Image Size

Once the installation is finished, you'll be shown a success screen, ensuring the setup was finished successfully.

NVM setup: setup successfully completed.
NVM setup: setup successfully completed.
View Original Image Size

Step 3 - Confirm the NVM Installation

To ensure it was installed on your system, run the following command in the terminal.

nvm version

It should output a version (1.1.9 as of writing this article) to confirm the installation.

Using the nvm version command to check the currently installed version of nvm.
Using the nvm version command to check the currently installed version of nvm.
View Original Image Size

Step 4 - Download Node.js

Type the following in the terminal to begin downloading Node.

nvm install lts

Using the nvm install lts command to install the LTS version of Node.js.
Using the nvm install lts command to install the LTS version of Node.js.
View Original Image Size

Step 5 - Confirm the Node.js Installation

To confirm the installation, type the following.

node -v

The installation was successful if the terminal outputs a version (v16.17.1 as of writing this article).

Using the node -v command to check the currently installed version of Node.js.
Using the node -v command to check the currently installed version of Node.js.
View Original Image Size

Step 6 - Use a Node.js Version

To use the currently downloaded version 16.17.1, type the following command in the terminal.

nvm use 16.17.1

This command is also used to switch between different Node.js versions.

Using the nvm use command to use the currently installed version of Node.js.
Using the nvm use command to use the currently installed version of Node.js.
View Original Image Size

Install Node.js on Windows with Its Installer

To install it using the installer, follow the steps mentioned below.

Step 1 - Download the Node.js Installer

To install the latest version, go to the official Node.js website and click on the 16.17.1 LTS button (as of writing this article) to download the installer.

You can also install the Current version by simply clicking its download button.

Node.js website.
Node.js website.
View Original Image Size

This will begin downloading the stable LTS.

Step 2 - Install Node.js

Once it successfully downloads, run the Node.js installer and follow the setup instructions to complete its installation.

Node.js setup: welcome screen.
Node.js setup: welcome screen.
View Original Image Size

You'll be asked to agree with the license agreement to proceed.

Node.js setup: license agreement.
Node.js setup: license agreement.
View Original Image Size

After accepting the license agreement, you'll be shown a screen to decide which custom features of Node.js you want to install. You may leave the settings as default and click the Next button.

Node.js setup: features selection.
Node.js setup: features selection.
View Original Image Size

On the next screen, you can choose if you want to install optional tools to compile native modules from C/C++ that require the installation of Python and Visual Studio Build Tools. Because some npm modules rely on these tools, you should only check this option if you plan to use those modules in the future.

If you choose to install these optional tools, Chocolatey will also be installed as part of them.

Generally, you don't need these optional tools, so you may safely choose not to install them. In any case, you can always install them later manually or using the installer.

Node.js setup: optional tools installation (Chocolatey, Python, and Visual Studio Build Tools).
Node.js setup: optional tools installation (Chocolatey, Python, and Visual Studio Build Tools).
View Original Image Size

After deciding on all these settings, you'll be shown a confirmation screen to proceed with the installation. Click Install to continue.

Node.js setup: setup is ready to install.
Node.js setup: setup is ready to install.
View Original Image Size

You'll be able to track the installation progress to ensure everything is going as expected.

Node.js setup: installation in progress.
Node.js setup: installation in progress.
View Original Image Size

Once installed, a final confirmation screen will be shown to ensure that Node.js is installed.

Node.js setup: setup successfully completed.
Node.js setup: setup successfully completed.
View Original Image Size

Step 3 - Confirm the Node.js Installation

To ensure it is successfully installed on your PC, run the below command in the command line.

node -v

If the output returns a version number (v16.17.1 as of writing this article), then that confirms the successful installation of Node.js on your system.

The version of the Node.js installed can also be found by using the same command.

Using the node -v command to check the currently installed version of Node.js.
Using the node -v command to check the currently installed version of Node.js.
View Original Image Size

Install npm on Windows

Even though npm comes pre-installed with the newer Node.js versions, you can always get it separately.

To get npm separately, type the following in the terminal.

npm install -g npm

Using the npm install -g npm command to download and install the latest version of npm.
Using the npm install -g npm command to download and install the latest version of npm.
View Original Image Size

The installation can be confirmed by opening the Command Prompt and typing the following command.

npm -v

If the terminal outputs a version (8.15.0 as of writing this article), then npm was installed successfully.

Using the npm -v command to check the currently installed version of npm.
Using the npm -v command to check the currently installed version of npm.
View Original Image Size

Conclusion

That's all. You have now successfully installed both, Node.js and npm. Now you can start developing your Node.js applications, web servers, or whatever it is that you need it for.

I hope this tutorial has been helpful to you and cleared any confusion you might have regarding the installation and setup.

Have you used Node before? Or, for what purposes do you plan to use it? Let me know your thoughts by sending me an email at [email protected].

Frequently Asked Questions

Can Node.js Be Installed on Windows?

Yes. Node.js can be installed on Windows, whether running Windows 11, 10, 8.1, 8, or 7. Follow the above installation steps to install it.

How Do I Install Node.js on Windows 10 or Other Versions?

To install Node on Windows 10, use the nvm install lts command in the terminal. Alternatively, follow the above installation steps of the tutorial for a detailed explanation.

Where Does Node Install on Windows?

Node.js is usually installed in the C:/Program Files/nodejs directory.

Additional Resources

Here are some helpful links if you'd like to read in-depth about some of the technologies and concepts mentioned above.

Contents

    Danial Zahid's headshot.

    About Danial Zahid

    I'm a self-taught web developer passionate about everything related to websites and web development. Over the past years, I've explored and worked with different web technologies and tools, notably WordPress, Eleventy, npm, and Gulp.js, to name a few.

    In addition, I've created and currently maintain several open-source projects, including web apps, widgets, websites, and more.

    When I'm not writing content for W3Things or doing web development work, I enjoy my free time by playing games or listening to podcasts.

    Get Essential Gulp Kit

    The ultimate Gulp.js solution to improve your developer experience.

    • Includes complete Gulp.js toolkit setup
    • Optimize website content and static assets
    • Continuous asset optimization during development phase
    • Optimize unlimited number of files in bulk
    • Plus many more awesome features

    Subscribe to the Newsletter

    This website uses cookies to optimize your site experience. By continuing to use the site, you are agreeing to its privacy policy and the use of cookies.