How to Install Node.js and NPM on Ubuntu 18.04, 20.04, and 22.04: 3 Methods
- 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.

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:
Connect to your server via SSH:
ssh username@server_ip_address
Update the Apt cache:
sudo apt update
Install Node.js:
sudo apt-get install nodejs
Confirm the installation when prompted by typing Y.
Install NPM:
sudo apt install npm
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.
Update your system:
sudo apt-get update sudo apt-get upgrade
If you don’t have cURL, install it:
sudo apt-get install curl
Add the NodeSource repository (replace 18.x with your desired version):
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
Install Node.js:
sudo apt-get install nodejs
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.
Install wget:
sudo apt-get install wget
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
Load NVM into your user’s Bash profile:
source ~/.profile
List available Node.js versions:
nvm ls-remote
Tip: Press Ctrl + C to stop the listing early.
Install a specific version (for example, the latest LTS):
nvm install 16.17.0
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.

Stuffy @ HolyHosting


















