Node.js is a popular open-source JavaScript runtime environment that allows developers to build fast and scalable applications. It is built on top of Google Chrome’s V8 JavaScript engine, which allows it to execute code quickly and efficiently. In this article, we will guide you through the process of installing Node.js on Ubuntu, Windows, and macOS.

Installing Node.js on Ubuntu

Installing Node.js on Ubuntu is a straightforward process. Follow these steps to install Node.js on Ubuntu:

So, to update the package list, open the Terminal by pressing Ctrl+Alt+T or by searching for “Terminal” in the Applications menu. Then, use the following command.

sudo apt update

the next step, Install Node.js and npm using the following command:

sudo apt install nodejs npm

An then, Verify the installation by checking the version of Node.js and npm:

node -v
npm -v

Congratulations! You have successfully installed Node.js on Ubuntu.

Installing Node.js an NPM on Windows

Installing Node.js on Windows is also a simple process. Follow these steps to install Node.js on Windows:

firstly, Download the Node.js Windows installer from the official website (

Install Node js

Secondly, double-click on the installer to begin the installation process.

Thirdly, follow the prompts in the installer to complete the installation.

And finally, Verify the installation by checking the version of Node.js and npm:

node -v
npm -v

Congratulations! You have successfully installed Node.js on Windows.

Installing Node.js on macOS

Installing Node.js on macOS is similar to installing it on Ubuntu. Follow these steps to install Node.js on macOS:

To get started, open the Terminal on your Mac by pressing Command+Space and searching for “Terminal”. Once you have the Terminal open, you can install Homebrew, a popular package manager for macOS, by running the following command:

/bin/bash -c "$(curl -fsSL"

The next step, you have to run the below command to Install Node.js and npm using Homebrew:

brew install node

And then, verify the installation by checking the version of Node.js and npm:

node -v
npm -v

Congratulations! You have successfully installed Node.js on macOS.

Install Node.js and NPM Using Binary Package on Windows

Installing or updating Node.js using binaries involves navigating to the Node.js official page and selecting a binary package suitable for your operating system from the list provided.

Install Node.js Using Binary Package.

Once you have downloaded the required package, you need to unzip it. In this case, we have downloaded the binary package of bit-64 “node-v16.15.1-win-x64.”.

Install Nodejs Using Binary Package

Once you have moved the folder, copy the path of its new location.

Copy The Nodejs Binary Location

To add the path of the Node.js binary folder located on your machine, you need to open the “Environment Variables.” This can be done by following these steps:

  • Right-click on “My Computer” using your mouse and select “Properties”.
Advanced System Settings
  • Scroll down and click on “Advanced System Settings” to open “System Properties.”
  • Click on the “Advanced” tab and then click on the “Environment Variables” button.
System Properties

Now click on “Path” and then click on the “Edit” button.

Variable Environment

In the next step, add the new path to the list of variables, as shown in the images below.

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

Updating Node.js Using Node Package Manager ( NPM )

NPM, which stands for Node Package Manager, allows you to update Node.js using a package from the NPM registry known as “n.” This package is responsible for managing all versions of Node.js. To install “n,” you can use the command provided in the npm registry.

To update or install Node.js using the “n” package, you need to execute one of the following commands:

n lts
n latest

Update Node.js Using Node Version Manager ( NVM )

As mentioned in the title, NVM stands for Node Version Manager, and this package assists in managing all versions of Node.js. If you have multiple versions installed, you can use the NVM command to switch between them.

If you do not have NVM installed on your machine, please refer to the NVM tutorial for instructions on how to install it.

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

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

Verify The Node.js and NPM Installation

Furthermore, to confirm the version of Node.js that you downloaded or to verify if the installation was successful, you need to execute the following code in the command prompt. To open the command prompt, go to the Start menu, type “command prompt” in the search bar, and open the application.

Command Prompt

Verify Node.js Version

node -v

Verify NPM Version

npm -v

Update Node Package Manager ( NPM )

You can use the npm command to update npm, which enables it to update itself. If you are using Ubuntu or macOS, please use the sudo command before executing the following command.

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

If you refer to the previous image, you will notice a warning message recommending using –location=global instead of the deprecated -g flag.

In the second message, you will see a new message stating “up to date,” which indicates that we have already installed the latest version of Node.js.

Node.js Usage

Additionally, to start a Node.js application, you need to create a new project folder and add the following code to a file named “server.js”.

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

Wrapping Up

In conclusion, Node.js is a powerful tool for building scalable and fast applications. Installing Node.js on Ubuntu, Windows, and macOS is a straightforward process that can be completed in just a few steps. By following the instructions in this article, you can start using Node.js and take advantage of its many benefits.