How to Install Node.js: A Comprehensive Tutorial

Introduction to Node.js

Node.js Logo

Node.js is an open-source, cross-platform, server-side runtime environment that is built on Chrome’s V8 JavaScript engine. It is built with the intention of creating highly-scalable, event-driven, and real-time applications. Node.js is perfect for building applications that require high I/O operations such as real-time chat applications, live streaming applications, social media applications, online games, and many more.

Node.js was created by Ryan Dahl in 2009 and has since then grown in popularity due to its ability to handle large amounts of data asynchronously. Node.js allows developers to write server-side applications in JavaScript, a language that is commonly used on the client-side. This means that developers can now use the same language on both the client and server-side, which reduces the need to learn another programming language, thus reducing the development time.

Node.js is also known for its powerful package manager called npm. npm hosts over 1 million packages that can be easily installed and integrated into your projects. This makes it easy for developers to reuse code and focus on building new features instead of reinventing the wheel.

In order to start using Node.js, you first need to install it on your machine. In the next subsection, we will go through the steps needed to install Node.js on different platforms.

Preparing to Install Node.js

Preparing to Install Node.js

Before diving into the installation process of Node.js, there are a few preparatory steps necessary to ensure that the installation process goes smoothly. Following these preparatory steps will ensure that your installation process is seamless and will save time in the long run.

1. Check Your System

Before installing Node.js, it is important to check your system’s requirements to ensure successful installation. Generally, Node.js can be installed on any operating system such as Windows, Linux, or macOS. The only requirement is that your operating system supports the latest version of Node.js, and it is recommended to have at least 2GB RAM and 2GHz processor speed for optimal performance. You can check the system requirements on the official Node.js website.

2. Choose the Right Version

It is important to choose the right version of Node.js for your project before installing it. There are two major release versions available – the Long-Term Support (LTS) version, and the Current version. The LTS version is more stable and receives updates only once a year. This version is ideal for those who want a stable version of Node.js for their project. The current version is updated more frequently, usually every three months or so, making it a good choice for those who want to take advantage of the latest features of Node.js. It is always recommended to choose the LTS version if you are not sure which version to install.

3. Remove Previous Versions of Node.js

It is essential to remove any previous versions of Node.js installed on your system before installing the latest version. This will prevent any compatibility issues and ensure that Node.js runs smoothly. To remove older versions, open the command prompt (on windows) or terminal (on macOS or Linux), and execute the following command:

$ sudo apt-get remove nodejs

4. Install a Package Manager

The installation of Node.js will automatically install the NPM package manager, which is needed to install or manage dependencies for your project. NPM provides functionality to install, uninstall, and manage dependencies for your project. If you want to use an alternative package manager, such as Yarn, then it is important to install it before installing Node.js to avoid any conflicting dependencies.

5. Backup Your System

It is always good to back up your system before installing new software or updates. In case anything goes wrong during installation, you will have a backup to rely on. You can use different backup methods such as system backups, cloud backups, or manual backups. Ensure that current project files, configurations, and important data are backed up before installing Node.js.

In conclusion, preparing to install Node.js involves checking your system, choosing the right version for your project, removing previous versions, installing a package manager, and backing up your system. Following these preparatory steps will ensure that the installation of Node.js will go smoothly, and that your project will run without any problems.

Installing Node.js on Windows

Node.js on Windows

If you’re a developer or have just started programming, then you must have heard of Node.js. It is an open-source, cross-platform, and JavaScript runtime environment. Node.js is built on the V8 JavaScript engine of Google Chrome and uses an event-driven, non-blocking input/output model to make it lightweight and efficient. It’s very popular among developers because of its capability to handle real-time applications, and it’s quite easy to install on Windows. In this article, we’ll give you a step-by-step guide on how to install Node.js on Windows.

Step 1: Downloading the Node.js installer

Node.js installer on Windows

The first step is to download the installer from the official Node.js website. We recommend downloading the LTS (Long-Term Support) version, which is stable and is supported for a more extended period. After clicking on the download link, the installer executable file will be saved to your Downloads folder.

Step 2: Installing Node.js

Node.js installation process on Windows

After downloading the installer, double-click on it to begin the installation process. You’ll first see the welcome screen with a license agreement. Read and accept the agreement to proceed to the next step.

Next, you’ll be asked to choose the components you want to install. For most cases, the default options are sufficient. However, if you’re required to choose, we suggest leaving everything selected and click the Next button.

After that, you’ll be prompted to select the installation directory. If you’re not sure, leave the default directory, and click Next. On the next screen, you’ll have options to customize the installation, such as adding the Node.js runtime environment path to the system’s environment variable. Generally, it is recommended to leave everything unchanged and click on the Next button.

After you have reviewed the final installation options, click on the Install button to start the installation process. It will take a few minutes to complete the installation. Once the installation is done, click on the Finish button to exit the installer.

Step 3: Verifying the installation of Node.js

Verify Node.js installation on Windows

To verify that Node.js is installed correctly on your Windows computer, open a command prompt by pressing the Windows key and typing “cmd” in the search bar. Open the command prompt using “Run as Administrator.” In the command prompt, type the following command:

node -v

If you receive a version number in response, such as v15.12.0, it indicates that Node.js is installed and working correctly.

Step 4: Install a Node.js package

Node.js package manager on Windows

After you have installed Node.js, you can also install various Node.js packages using the Node Package Manager (NPM). NPM is pre-installed with Node.js and allows you to install and manage packages. To install a package, open a command prompt and type the following command:

npm install < package_name >

Replace the < package_name > with the actual name of the package you want to install. For example, if you want to install express to create a web server, type:

npm install express

The above command will download and install the express package to your computer, and you can use it to create a web server. Congratulations! You have now installed Node.js on your Windows computer and have installed an additional package using NPM.

Installing Node.js on MacOS

Installing Node.js on MacOS

If you are a developer working on a MacOS system, then you need to install Node.js on your machine to be able to use JavaScript on the server side. The process of installing Node.js on MacOS is fairly simple, and this tutorial will guide you through the steps.

Before you start, make sure that you have a stable internet connection and a web browser installed.

Step 1: Verify whether Node.js is already installed

The first step is to check if Node.js is already installed on your Mac. Open the terminal on your Mac by clicking on the spotlight search and typing ‘terminal’ in the search bar. Once the terminal opens, type ‘node-version’ command in the terminal and hit enter. If Node.js is not installed, the terminal will display a message like ‘command not found.’ If you have Node.js already installed, it will display the version number.

Step 2: Install Homebrew

Installing Homebrew is the most convenient way to install Node.js on your Mac. Homebrew is a package manager that allows you to install different software packages and dependencies on your Mac. To install Homebrew, go to the terminal and type the following command:

/usr/bin/ruby -e “$(curl -fsSL”

You will be prompted to enter your system’s administrator password. Enter the password, and Homebrew will start installing on your system. Once the installation is complete, type ‘brew -v’ in the terminal and hit enter. This will display the version number of Homebrew.

Step 3: Install Node.js using Homebrew

Now that Homebrew is installed, you can use it to install Node.js. In the terminal window, type the following command:

brew install node

Homebrew will start downloading and installing Node.js on your Mac. The installation may take a few minutes, depending on your internet speed. Once the installation is complete, type ‘node -v’ in the terminal to verify the installation. If everything was installed correctly, the terminal will display the version number of Node.js.

Step 4: Updating Node.js using NPM

Node.js releases new versions regularly, and it is essential to keep your installation up-to-date to ensure you have access to the latest features and security fixes. NPM is the default package manager for Node.js, and it is easy to use to update Node.js. In the terminal, type the following command:

sudo npm cache clean -f

This command will clear the NPM cache and make way for the new installation. Then type:

sudo npm install -g n

This command will install the N package, which is a version manager for Node.js. Finally, to update to the latest version of Node.js, type:

sudo n latest

Once the command finishes executing, verify that you have the latest version of Node.js installed on your Mac by typing ‘node -v’ in the terminal.

That’s it! You’ve successfully installed Node.js on your Mac using Homebrew and updated it to the latest version using NPM. You’re now ready to start developing applications using the power of Node.js.

Installing Node.js on Linux

Installing Node.js on Linux

If you are a Linux user, there is a high chance that you will find Node.js installed in your system. However, the version that is installed in your system may not be the latest version of Node.js. Therefore, to install the latest version, you need to follow the steps mentioned below:

Step 1: Install Node.js Using Package Manager

The easiest way to install Node.js on Linux is by using the package manager. The most common package managers for Linux are apt-get and yum. The following are the commands to install Node.js using apt-get and yum:


sudo apt-get update

sudo apt-get install nodejs


sudo yum install epel-release

sudo yum install nodejs

You can use the above commands to install Node.js on Debian, Ubuntu, CentOS, Fedora, and other Linux distributions that use these package managers.

Step 2: Install Node.js from Binary Archive

If you want to install the latest version of Node.js that is not available in the package manager, you can install it from the binary archive. Here are the steps to install Node.js from the binary archive:

  1. Visit the official Node.js website and download the binary archive for your Linux distribution (
  2. Extract the contents of the binary archive to a folder in your system.
  3. Open the terminal and navigate to the folder where you have extracted the binary archive.
  4. Run the following command to copy the files to the /usr/local/ directory:

sudo cp -r * /usr/local/

After running the above command, you should be able to use Node.js without any issues.

Step 3: Install Node Version Manager (NVM)

If you want to install multiple versions of Node.js on your Linux system, the best way to do it is by using Node Version Manager (NVM). NVM allows you to install and manage multiple versions of Node.js on your system.

  1. Open the terminal and run the following command to download the NVM installation script:

curl -o- | bash

Replace v0.38.0 with the latest version of NVM, which you can find on the official NVM GitHub repository (

  1. After downloading the installation script, run the following command to install NVM:

source ~/.bashrc

This command will add the NVM environment variables to your system so that you can use NVM to install and manage multiple versions of Node.js on your system.

Step 4: Install and Use Multiple Versions of Node.js with NVM

After installing NVM, you can use it to install and manage multiple versions of Node.js on your system. Here are the steps to install a specific version of Node.js:

  1. Open the terminal and run the following command to install the latest LTS version of Node.js:

nvm install --lts

  1. To install a specific version of Node.js, run the following command, replacing x.x.x with the version number:

nvm install x.x.x

After installing a specific version of Node.js, you can use the following command to switch to that version:

nvm use x.x.x

You can use NVM to switch between multiple versions of Node.js on your system.

Step 5: Add Node.js to PATH Environment Variable

To use Node.js from the command line, you need to add it to the PATH environment variable. Here are the steps to add Node.js to PATH:

  1. Open the terminal and run the following command to open the .bashrc file:

sudo nano ~/.bashrc

  1. Add the following line to the end of the file:

export PATH=$PATH:/usr/local/bin

This command adds the Node.js binary directory to the PATH environment variable.

  1. Save the changes and exit the editor.
  2. Run the following command to refresh the .bashrc file:

source ~/.bashrc

After following the above steps, you should be able to use Node.js from the command line in your Linux system.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top