UbuntuUbuntu Based

How To Install Node.js on Ubuntu 24.04 LTS

Install Node.js on Ubuntu 24.04

In this tutorial, we will show you how to install Node.js on Ubuntu 24.04 LTS. Node.js has become an essential tool for modern web development, enabling developers to build scalable, high-performance applications using JavaScript on both the client and server sides. As Ubuntu 24.04 gains popularity among developers, it’s crucial to understand how to install and set up Node.js on this powerful Linux distribution.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Node.js on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install Node.js on Ubuntu 24.04 LTS Noble Numbat

Step 1. Updating the Package Repository.

To prepare your system for the Node.js installation, start by updating the package list using the following command:

sudo apt update

This command will fetch the latest package information from the Ubuntu repositories, allowing you to install the most recent version of Node.js and its dependencies. Updating the package repository is crucial to maintaining the security and stability of your system.

Step 2. Installing Node.js on Ubuntu 24.04.

  • Method 1: Installing Node.js Using APT

The APT package manager is the simplest and most straightforward method to install Node.js on Ubuntu 24.04. Follow these steps to install Node.js using APT:

sudo apt install nodejs npm

Verify the installation by checking the installed versions:

node -v
npm -v

If the installation is successful, these commands will display the installed versions of Node.js and npm, respectively.

Using APT ensures that you install a stable version of Node.js that is compatible with your Ubuntu 24.04 system. However, the version provided by the default repositories might not always be the latest release.

  • Method 2: Installing Node.js Using NVM (Node Version Manager)

NVM is a powerful tool that allows you to manage multiple Node.js versions on the same system. This is particularly useful for developers who work on projects requiring different Node.js versions. To install Node.js using NVM, follow these steps:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

Restart your terminal or run the following command to apply the changes:

source ~/.bashrc

Verify the NVM installation:

nvm --version

Install the desired Node.js version using NVM:

nvm install 20.0.0

Replace 20.0.0 with the specific Node.js version you want to install.

Set the installed version as the default:

nvm alias default 20.0.0

NVM provides flexibility in managing Node.js versions, making it easy to switch between different versions for various projects.

  • Method 3: Installing Node.js from the Official Node.js Binary

If you prefer to install Node.js directly from the official binary, follow these steps:

wget https://nodejs.org/dist/v20.12.2/node-v20.12.2-linux-x64.tar.xz

Extract the downloaded archive:

tar -xvf node-v20.12.2-linux-x64.tar.xz

Move the extracted directory to /usr/local:

sudo mv node-v20.12.2-linux-x644 /usr/local/node

Set up the environment variables:

echo 'export PATH=/usr/local/node/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

Verify the installation:

node -v
npm -v

Installing from the official binary provides the latest Node.js version and offers more control over the installation process.

Congratulations! You have successfully installed Node.js. Thanks for using this tutorial for installing the Node.js on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the Node.js website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button