Install Node.js and NPM on Windows 10 or 11 using command line

This tutorial will discuss the command line way to install Node.js and NPM quickly on Windows 10 or 11 using the PowerShell or Command prompt.

Node.js and its NPM which stands for ‘Node package manager’ are widely used by developers around the world for developers’ modern applications. Both are open-source and cross-platform, hence the operating system is not a limitation at all. Nodejs which offers a back-end JavaScript runtime environment allows developers to build scalable network applications. Whereas, to install dependencies and other supported packages to build an app, NPM, a Node Package Manager is there. 

Although Node.js is cross-platform, its process of installation is different as per the operating system you are using. When it comes to Windows, most of the time users manually visit the website of Nodejs to download its executable file to perform the installation. However, you don’t need to do that because Windows 10 and 11 come with an inbuilt package manager like Linux known as Winget.

And in this article, we will provide a step-by-step guide to installing Node.js and NPM on Windows 10 or 11 using the command terminal.

Those who are not interested in the CLI way can still go for the traditional GUI way for downloading and installing Node.js and NPM on Windows 10 or 11.

Use CMD or Powershell to install Node.js & NPM on Windows 10 or 11 

Prerequisites â€“ Before installing Node.js and NPM on Windows, it is important to ensure that the following prerequisites are met:

  • You are using Windows 10 or 11
  • Access the Administrator user account
  • Active Internet connection 

1. Open PowerShell as Admin

Here we are using Powershell, however, you can use the Command prompt as well; the given steps in this article will be the same for both.

Right-click on the Windows 10 or 11 start menu and select Terminal (Admin) in Windows 11. Whereas Windows 10 users would have Powershell (Admin) option. 

2. Check Winget is Available

Winget is a package manager developed by Microsoft for its Windows operating system to easily install an application using the command line. So, first, let’s check whether it is available on our system or not. Well, by default it will be there. if not, then you can install it manually from GitHub.

winget

You will get something like the below in the given screenshot which confirms, the package manager is working fine. 

Check Winget is available or not

3. Command to Install Node.js LTS or Current version

Node.js comes with NPM, so installing it will also configure the package manager. Som on your command prompt or terminal, type the given command to check the availability of Nodejs packages:

winget search node.js

You will see all the available versions of Node to install on Windows using the Winget package manager such as LTS, Current, and Nighlly. 

Search for Node package using winget

Let’s see how to download them using the command given below, choose only one as per the version you want on your system.

For Node.js & NPM LTS version, the command will be:

winget install OpenJS.NodeJS.LTS

For Node.js and NPM Current version 

winget install OpenJS.NodeJS

To get the Nightly version (testing)

winget install OpenJS.NodeJS.Nightly
Install Nodejs and NPM on Windows using Command pompt

4. Testing the Installation by checking the version

Once you are done with the installation, let’s confirm the required version of Node.js and NPM are on Windows by running a simple command in the command prompt or Powershell. However, before running them close and reopen the command prompt.

Check the version of Node.js by typing

node -v 

Check the version of NPM by using 

npm -v
Check NPM and Node versions

Conclusion 

Using the command line to install Node.js and NPM on Windows is quite easy as compared to the graphical way in which we manually have to download the installer by using a browser and visiting the software website. By following the steps given in this article, developers can ensure that they have the latest version of Node.js and NPM installed on their Windows computers for creating scalable network applications using JavaScript.

Other Articles: