A Quick Guide to Setting Up Node.js 22 LTS on Ubuntu

By XaHertz  |  September 21, 2024  |  Last Updated : December 17, 2025

Node.js is a powerful and efficient JavaScript runtime built on Chrome’s high-performance V8 engine, and it is widely used for creating fast, scalable, and event-driven network applications. It allows developers to run JavaScript on the server side, making it a popular choice for building APIs, real-time applications, and full-stack solutions.

In this article, we’ll walk you through the step-by-step process of installing Node.js 22 LTS on an Ubuntu-based system, explaining the recommended methods and verifying the installation, so you can confidently set up your development environment and start building with Node.js right away.

Prerequisites

Before you begin the installation, ensure you have:

  • An Ubuntu-based system (version 20.04 or later recommended)
  • Sudo privileges for installing packages

Installation Steps

Step 1: Update System Packages

It's essential to start by updating your system packages to ensure all software is up-to-date. Open your terminal and run the following command:

sudo apt update

Step 2: Install Curl

Now before you begin, make sure that curl is installed on your machine. Curl is necessary for downloading the Node.js setup script. If it's not installed, you can install it using this command:

sudo apt install -y curl

Step 3: Download Node.js Setup Script

Next, download the Node.js LTS setup script from Nodesource. This script configures the necessary repository for Node.js installation.

curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh

Step 4: Run the Node.js Setup Script

Execute the downloaded setup script to configure the repository:

sudo -E bash nodesource_setup.sh

Step 5: Install Node.js

Now, install Node.js using the apt package manager:

sudo apt install -y nodejs

Step 6: Verify Node.js Installation

Finally, confirm that Node.js is installed correctly by checking its version:

node -v

You should see the Node.js version number printed in the terminal, indicating a successful installation.

Troubleshooting Tips

  • If you encounter issues with downloading the setup script, ensure that your internet connection is stable.
  • For permission-related errors, double-check that you have sudo privileges.
  • If Node.js installation fails, try running sudo apt update again and repeat the steps.

Final Thoughts

Setting up Node.js LTS on Ubuntu is straightforward with the steps outlined above. By following the steps in this article, you now have a robust environment for developing and running Node.js applications.


Last updated on December 17, 2025