top of page

How to Install Node.js and NPM on Ubuntu 18.04, 20.04, and 22.04: 3 Methods

  • Writer: HolyHosting
    HolyHosting
  • Oct 30
  • 3 min read

Node.js is one of the most popular web technologies available today. As a developer, you may want to use it to enhance your web application’s functionality or set up a local development environment.

In this article, we’ll explain how to install Node.js on a Linux system running Ubuntu 18.04, 20.04, or 22.04. This installation method works for both local Ubuntu systems and VPS hosting services.

We’ll show you how to install Node.js on Ubuntu using the default repositories and NodeSource. Finally, you’ll learn how to install a specific Node.js version using NVM.

ree

What Is Node.js?

Node.js is a server-side runtime environment that allows users to execute JavaScript code on the server. It’s an open-source, cross-platform project ideal for both educational and business-oriented development.

Node.js is especially useful for handling data-intensive tasks and building scalable network applications. Common use cases include real-time chat, data streaming, and server-side proxies.

Although the latest Node.js version is 18.9.0, we recommend using 16.17.0, the current Long-Term Support (LTS) version. However, always check the Node.js download page for the most recent version, as updates are released frequently.

Important: Before proceeding, make sure you have server access and a non-root user account capable of running sudo commands in Linux. See our guide on how to connect to a VPS via SSH for more details.

Installing Node.js and NPM Using Apt from the Default Repositories

One efficient way to install Node.js on Ubuntu is through its official distribution repository. Systems running Ubuntu 18.04 or newer include Node.js and Node Package Manager (NPM) in the default repository.

However, this method doesn’t let you choose which version to install. In other words, it may install an outdated version that’s no longer supported.

Pro Tip:If you prefer not to install Node.js manually, consider using one of our VPS OS templates with Node.js preinstalled. Visit HolyHosting’s Node.js server hosting page for more details.

Before installing Node.js, open your terminal from the main menu or press Ctrl + Alt + T. Then follow these steps to install Node.js on your VPS using the Apt package manager:

  1. Connect to your server via SSH:

    ssh username@server_ip_address

  2. Update the Apt cache:

    sudo apt update

  3. Install Node.js:

    sudo apt-get install nodejs

  4. Confirm the installation when prompted by typing Y.

  5. Install NPM:

    sudo apt install npm

  6. Check the installed versions:

    nodejs -v npm -v

If you ever need to remove Node.js or NPM, use:

sudo apt remove nodejs
sudo apt remove npm

Installing Node.js Using Apt from NodeSource

Another way to install Node.js is through a Personal Package Archive (PPA) such as NodeSource. Compared to Ubuntu’s default repository, NodeSource offers a wider range of versions.

This method is ideal if you need a specific or the latest version of Node.js.

  1. Update your system:

    sudo apt-get update sudo apt-get upgrade

  2. If you don’t have cURL, install it:

    sudo apt-get install curl

  3. Add the NodeSource repository (replace 18.x with your desired version):

    curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

  4. Install Node.js:

    sudo apt-get install nodejs

  5. Verify installation:

    node -v npm -v


Installing a Specific Version of Node.js Using NVM

You can also install Node.js with Node Version Manager (NVM), a Bash script for managing multiple Node.js versions.

This method is ideal when you need to switch between different Node.js versions easily.

  1. Install wget:

    sudo apt-get install wget

  2. Download and install NVM (replace v0.39.0 with your preferred version):

    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.39.0/install.sh | bash

  3. Load NVM into your user’s Bash profile:

    source ~/.profile

  4. List available Node.js versions:

    nvm ls-remote

    Tip: Press Ctrl + C to stop the listing early.

  5. Install a specific version (for example, the latest LTS):

    nvm install 16.17.0

  6. Confirm the active version:

    node -v


Node.js is a powerful server-side JavaScript runtime that enables you to build scalable network applications efficiently. Developers frequently use it for handling data-intensive processes and real-time analytics.

In this article, we covered three methods to install Node.js on Ubuntu 22.04 or earlier versions. Make sure you can use sudo and connect to your VPS before starting.

You can:

  • Install Node.js from Ubuntu’s default repository using Apt.

  • Use NodeSource for more version options.

  • Install and manage multiple versions with NVM.

By following these methods, you’ll have Node.js up and running on your VPS or local Linux system in no time.


Conclusion

We hope this guide has been helpful! 🚀 Remember, don’t hesitate to ask questions on the HolyHosting Discord or contact our support team.

Follow us on Twitter @HolyHosting to stay up to date.

ree

Stuffy @ HolyHosting

 
 

Related Posts

See All
How to Fix the "Mismatched Mod Channels" Error

Hello, HolyHosting players! 🌟We know that playing on modded servers is super fun, but it can also be a headache 🧠 when your mods don’t match between your game and the server. 😩 Here’s how to fix th

 
 

CREATE YOUR SERVER

READY TO GET STARTED?

Start today and we’ll offer you a 25% discount on your first bill with our new customer promotion!

Etiqueta.png
View active promotions and coupons
holyhosting logo

Powerful servers at affordable prices.

HolyHosting

Copyright © 2025 HOLY SERVERS LLC, operating under the name HolyHosting.

REG. NO.: 001599788. This business entity is officially registered at 30 N Gould St, Suite N, Sheridan, WY 82801, Wyoming, US.

  • X
  • Instagram
  • Facebook
  • Discordia
  • YouTube
  • Tik Tok

POPULAR

US

SUPPORT

Minecraft
Minecraft Dedicated Hosting
Discord Bot Hosting
Other Games Hosting
Voice Server Hosting
MC Servers Panel
Games Servers Panel

About Us
Client Area
Branding
Payment Methods
Hardware by Location
Terms and Conditions
Privacy Policies
Refund Policies

Create a Ticket
Knowledge Base
Discord
Network Status
Request Affiliation

dmca

Copyright © 2025 HOLY SERVERS LLC, operating under the registered name HolyHosting. All rights reserved.

The payment process may be handled by Tebex Limited, acting as the registered merchant and being responsible for product fulfillment and handling billing inquiries.

bottom of page