How to install Node.js on Ubuntu 22.04?

Overview

Node.js is a JavaScript general-purpose programming framework that allows users to easily develop network applications. It is an open-source server and makes development more consistent and integrated by employing JavaScript on both the front and backend.

This tutorial will show you how to install Node.js on Ubuntu 22.04.

Prerequisites

There are certain prerequisites that need to be met before you begin.

  • Server with Ubuntu 22.04

  • Non-root user (sudo-enabled)

Key

  • Red Color: Input

  • Green Color: Output

Common prompts

  • When using sudo to execute a command, you might be asked for your user password.

  • When a command is executed, you could be asked if you wish to carry it out further or not. Enter "Y" to proceed or "n" to end, and then press ENTER.

Get Started

Step 1: Update all dependencies

i. Run the below command to fetch the package information from all configured sources.

sudo apt-get update

Step 2: Download installation package

Run the below command to download and install the package fetched above.

sudo apt-get upgrade

Step 3: Install Node.js

Use the following command to install Node.js to your server.

sudo apt install nodejs

Step 4: Check Node.js version

Once you’ve installed Node.js, now you can check the Node.js version with the below command:

node --version

Step 5: Install Node Package Manager

Use the command shown below to install npm (Node Package Manager) to install Node.js-compatible modules and packages:

sudo apt install npm

Now, Node.js and npm have now been successfully installed.

Please watch the video for instructions on how to execute the above-mentioned command.

Last updated