This tutorial will teach you how to install node js and NPM on windows.

Node.js is an open-source and javascript runtime environment built-in Google V8 Chrome’s JavaScript Engine to help users in network applications working outside the browser client and create server-side web applications.

Table Of Contents

NPM is a Node Package Manager, a giant repository or large online store with over 1.3 million packages. Those packages are developed by JavaScript users called publishers. To serve up the javascript platforms and their technologies.

Prerequisites

  • Command-Line Interface ( CLI )
  • ROM 256 GB
  • CPU Intel Core i3
  • RAM 4GB

Since we’ve decided to develop the applications using node.js, it is required to install node js and NPM environment software on the operating systems. And to do that, we have to explain the installation process step by step.

Download The Node.js Installer

The installer we are looking for is found on Nodejs.org. Open the page and choose the correct installer according to your operating system. And make sure that you are downloading the latest version for Node.js. And don’t worry about NPM because the node.js installer already includes it.

Install Node js

The previous image shows you the first red rectangle for the downloaded installer, including version 16.15.1 for node.js and version 8.11.01 for NPM

In the same image, if you look at the bottom part, you will see many other installers for node.js, which helps you find 32-bit or different old versions.

Installing Node.js and NPM

After the download is finished, you have to select the .msi installer and double-click. The OS will request you to give access to run the program. Once you do it, you will see the setup wizard screen.

Node.js Setup Wizard Screen

On the wizard screen, you will see the welcome message. You need to click on the “Next” button. To allow the application starts the setup process.

In the next step, you have to check the checkbox to accept the terms of the license agreement. once you check it, click on the “Next” button.

Accept The Terms Of Node.js Software

It will ask you where you want to store the installation files. We recommend you to remain it as a default desired file location. But if you need to change the desired path, click on the “Change” button and select the new path.

You have to click on the “Next” button.

Change The Desired Path File For Node.Js File Installation

Once you click the next button, it will show you another screen containing the custom setup.

You have only to choose the NPM Package Manager choice. then click on the “Next” button

Choose the npm package manager choice

Here we have to explain all features shown in the previous image.

  • Node.js Runtime: the default core node.js runtime. This feature requires 58MB on your hard desk.
  • CorePack Manager: This refers to the universal package manager. Only it requires 772 KB.
  • NPM Package Manager: This refers to the node package manager requiring only 12 MB.
  • Online Documentation Shortcuts: It includes the online documentation for node.js and the node.js official website.
  • Add To Path: refers to adding all globally installed by NPM like Node.js, NPM, and modules to the path environment variable.

The next step shows you the optional screen for the tools of native modules. If you decide to check the checkbox, it will install some other tools and chocolatey automatically once the current installation is finished.

Tools For Native Modules

Are you ready to install?

You only have to click the “Install” button to start the installation process.

Install Node.js and NPM Using Binary Package on Windows

To install or update Node.js using binaries, you must navigate to the Node.js official page. You will see a list of binary packages. You have to select one from them according to your operating system.

Install Node.js Using Binary Package.

Once you download the needed package, you have to unzip it. We already downloaded the binary package of bit-64 “node-v16.15.1-win-x64“.

Next, we need to move this folder into our “program files” folder. It will show you access denied. Just click on the “Continue” button.

Install Nodejs Using Binary Package

Then explore this folder and copy the path of the new location.

Copy The Nodejs Binary Location

In the next step, open the “Environment Variables” through the following steps.

  • On my computer and using your mouse, right-click and click properties.
Advanced System Settings
  • Scroll down and click on “Advanced System Settings.” It will open “System Properties.”
  • Now click on the “Advanced” tab and then click on the “Environment Variables” button.
System Properties

Here we need to add the path of the Node.js binary folder located in our machine.

Variable Environment

Here we need to click on “Path” and then click on the “edit” button.

In the next step, we need to add the new path to these variables list, like the below image.

Add New Variable To Variable Environment in Installing Node.js Using Binary Package

Updating Node.js Using Node Package Manager ( NPM )

NPM stands for Node Package Manager. And you can update Node.js using a package in the NPM registry for the node version called “n.” n is responsible for managing all Node.js versions. And to install it, use the command in the npm registry.

To update or install node.js using the “n” package, you have to run one of the following commands.

n lts
n latest

Update Node.js Using Node Version Manager ( NVM )

As we mentioned in the headline, the NVM means Node Version Manager. And this package helps us to manage all versions of the node.js.

If you have more than one version, you can switch between them using the NVM command.

If you don’t have NVM on your machine go to NVM tutorial

-- NVM Command 
nvm install {The New Version} --reinstall-packages-from={The Old Version}

-- Example
nvm install 16.15.1 --reinstall-packages-from=10.4

For more details about nvm, please go to NVM tutorial.

Verify The Node.js and NPM Installation

To verify which version you downloaded or detect if everything has already been installed correctly, you have to run the below code using the “command prompt.” To open “command prompt,” open the window, start, then write in search “command prompt.”

Command Prompt

Verify Node.js Version

node -v

Verify NPM Version

npm -v

Update Node Package Manager ( NPM )

We can use the npm command to update the npm, which means it can update itself. if you are using ubuntu, macOS use sudo before the following command.

npm update npm@latest -g
npm update node.js

If you see the previous image, there is a warning message telling us to use --location=global instead of the -g flag. Because the -g flag is already deprecated.

If you see the second message. There is a new message “up to date” because we already installed the latest version from node.js.

Node.js Usage

To start the node.js application, you must create a folder for the new project and write the code below inside the “server.js” file.

console.log("Hello world");

In the next step, open the CLI in the same file path and run the below command.

node server.js

the result should be like the below image

Node.js Usage

Conclusion

You learned how to install Node.js and NPM on Windows in more than three ways. And when you install Node.js, it will install NPM automatically during the installation process.

Otherwise, we learned how to manage the versions of Node.js using NVM ( Node Version Manager ).