Oct 16, 2023 5 min read

How to Install Node.js and NPM on Windows

Install node.js and npm on windows with our step-by-step tutorial. A run-time environment that has the components required to run JS program.

Install Node.js and NPM on Windows
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install Node.js and npm on Windows, let's briefly understand - What is Node.js?

Node.js is a run-time environment that has all the components required to run a JavaScript program. It is used to execute scripts on the server that produce content before it is sent to a web browser.

Npm (Node Package Manager) is the default package manager for Node.js, providing access to a vast ecosystem of open-source libraries and tools.

In this tutorial, we will explore the steps required to install Node.js and npm on a Windows operating system. We will also address a few FAQs on how to install Node.js and NPM on Windows.

Advantages

  1. Efficient Development: Node.js offers a fast and scalable environment for server-side development, allowing developers to write JavaScript both on the front-end and back-end, streamlining the development process.
  2. Vast Package Ecosystem: npm provides access to a vast ecosystem of open-source packages, making it easy to integrate pre-built functionality into your Node.js applications, saving time and effort.
  3. Server-Side Rendering: With Node.js, you can perform server-side rendering, enabling faster initial page loading, optimization for search engines, and improved overall performance for your web applications.
  4. Real-time Applications: Node.js excels in building real-time applications, such as chat apps or collaborative tools, due to its event-driven architecture and the ability to handle thousands of concurrent connections.
  5. Cross-platform Compatibility: Node.js is designed to be cross-platform, allowing you to develop and deploy applications that run smoothly on Windows, macOS, and Linux, ensuring flexibility and compatibility.

Prerequisites

  • A user account with administrator privileges (or access to download and install software).
  • Access to the command line in Windows (search > cmd > right-click > run as administrator) OR Windows PowerShell (search > Powershell > right-click > run as administrator)

Step 1: Download Node.js Installer

Open a browser and go to https://nodejs.org/en/download/. To get the latest default version, use the Windows Installer button. Version 10.16.0-x64 was the latest version at the time this article was written. The Node.js installer comes with the NPM package manager.

💡
Note: There are various versions available. If you have an older system, the 32-bit version may be required. To switch from the current version to the stable LTS version, use the top link. Use LTS if you are new to Node.js or do not require a specific version.

Step 2: Install Node.js and NPM from your Browser

01. Open the installer after it has finished downloading. Select the file after opening the downloads link in your browser. Instead, you can double-click the file by navigating to the location where you stored it to start it.

02. Click Run when the system prompts you to run the software.

03. Choose Next when you are greeted by the Node.js Setup Wizard.

04. Examine the license agreement on the next screen. If you are ready to install the software and accept the terms, click Next.

05. The installer will ask you where you want to install it. Select Next after selecting the default location unless you have a reason to install it somewhere else.

06. You can choose which components to include or leave out of the installation using the wizard. Again, select Next to accept the settings unless you have a specific need to change them.

07. To launch the installer, click the Install option. Click Finish when it is complete.

Step 3: Verify Installation

Type the following into a command prompt (or PowerShell):

node -v

The system should show the Node.js version that is presently installed on your system. The same applies to NPM:

npm -v

Instructions to Update Node.js and NPM on Windows

The simplest method for updating Node.js and NPM is to get the most recent version of the software. The latest version will be shown just under the Windows Installer link on the Node.js download page. This can be compared to the version you have installed.

Download the installer, then launch it to upgrade. The setup wizard will substitute the previous version with the new one.

Steps to Uninstall Node.js and NPM on Windows

You may uninstall Node.js from the Windows Control Panel.

To do so:

  • Choose Start > Settings (the gear icon), then Apps.
  • Find Node.js by scrolling down and clicking to highlight.
  • Select Uninstall. This initiates a wizard to uninstall the software.

Basic Node.js Usage

Basic Node.js Usage
Node.js is a framework, so it does not function like a typical application. Instead, it interprets the commands you type. In order to test your new Node.js installation, create a Hello World script.

01. Start by opening your preferred text editor.

02. After that, copy the following and paste it into the text editor you just opened:

var http = require('http');
 http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'text/html'});
   res.end('Hello World!');
 }).listen(8080);

03. Save the document, then close it. Launch PowerShell and type the following, remember to enter the correct path of the script:

node \users\your_username\myprogram.js

It will appear that nothing has changed. Your script is actually being run in the background. If Windows Defender displays a warning about allowing traffic, click Allow for the time being.

04. After that, launch a browser and enter the following into the address bar:

http://localhost:8080

You should see the text Hello World! in the upper-left corner.

Your computer is currently acting as a server. The Hello World message will be displayed on any other computer that tries to access your system via port 8080.

Go back to PowerShell and type Ctrl+C to end the program. The command prompt will pop up once more on the system. When you are ready, you can close this window.

FAQ's on how to install Node.js and Npm on Windows

What versions of Windows are compatible with Node.js and npm?

Node.js and npm are compatible with various versions of Windows, including Windows 10, Windows 8, and Windows 7.

Where can I download the Node.js installer for Windows? 

You can download the official Node.js installer for Windows from the Node.js website (https://nodejs.org).

Do I need administrative privileges to install Node.js and npm on Windows? 

Yes, you need administrative privileges to install Node.js and npm on Windows. Right-click on the installer and select "Run as administrator".

Does the Node.js installer include npm? 

Yes, the Node.js installer includes npm by default. It is installed automatically alongside Node.js.

Can I install Node.js and npm using a package manager like Chocolatey? 

Yes, you can use package managers like Chocolatey to install Node.js and npm on Windows. Run choco install nodejs in an elevated command prompt to install them.

Are there any other package managers available for managing Node.js packages on Windows? 

Apart from npm, you can use other package managers like Yarn to manage Node.js packages on Windows. They provide additional features and improve package management workflows.

Can I use a proxy during the installation of Node.js and npm on Windows? 

Yes, if you need to use a proxy, you can configure Node.js and npm to use it by setting the appropriate environment variables or using the npm config command.

Conclusion

With Node.js, you can build efficient and scalable server-side applications using JavaScript, leveraging its fast performance and vast package ecosystem available through npm.

Node.js enables you to develop real-time applications and perform server-side rendering, enhancing user experience and application performance.

If you have any suggestions or queries, kindly leave them in the comments section.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.