Come chat with us and we will get back to you as soon as possible!
Contact SupportHolyHosting
Holy Team

Node.js is one of the most popular web technologies available today. As a developer, you may want to use it to enhance the functionality of your web application or create a local development environment.
In this article, we will explain how to install Node.js on a Linux system running Ubuntu 18.04, 20.04 and 22.04. This installation method works with local Ubuntu-based systems and VPS services.
We will show you how to install Node.js on Ubuntu using the default repositories and NodeSource. Finally, you will learn how to install a specific version of Node.js using NVM.
What is Node.js?
Node.js is a server-side runtime environment that allows users to run JavaScript code on the server side. It is a cross-platform open-source project, ideal for education-oriented and business-oriented projects.
Node.js is particularly useful for handling data-intensive tasks and developing scalable network applications. Some popular use cases include real-time chat, data streaming and server-side proxies.
Although the most recent version of Node.js is 18.9.0, we recommend using version 16.17.0, as it is the long-term support (LTS) version. Regardless, always check the Node.js downloads page for the latest version, as it is updated quite frequently.
Important! Before continuing, make sure you have server access and a non-root user account to run sudo commands on Linux. Read our guide to learn more about how to access a VPS via SSH.
How to Install Node.js Using Apt and NPM From the Default Repositories
An efficient way to install Node.js on Ubuntu is to use the official distribution repository. A system running Ubuntu 18.04 or later includes Node.js and Node Package Manager (NPM) packages in the default repository.
However, this method does not allow you to choose which version of Node.js to install. In other words, it may install an outdated version that is no longer supported.
Pro Tip
If you do not want to install Node.js manually, choose one of our VPS operating system templates with Node.js already pre-installed. For more information about this option, visit the HolyHosting Node.js server hosting page.
Before installing Node.js, open the terminal from the main menu of your system or press the key combination Ctrl + Alt + T. Follow these steps to install Node.js on your VPS using the Apt package manager:
Connect to the server using ssh by entering the following:
ssh username@server_ip_address
Update the Apt cache to refresh the repository:
sudo apt update
Updating the apt package manager using the Terminal
Enter the system password and press Enter.
After completing the update, install Node.js by entering the following command:
sudo apt-get install nodejs
Installing Node.js from the default repository
Type Y and press Enter to start the installation process.
Once the installation is complete, install the Node.js NPM package manager by running the following:
sudo apt install npm
Installing NPM from the default repository
Enter your password and confirm the installation.
Finally, verify the Node.js and NPM version numbers to confirm that the installation was successful. The command line will display the installed version number after entering these commands:
nodejs -v
npm -v
Verifying the installed Node.js and NPM versions from the Terminal
If you want to remove Node.js or NPM from the Linux system, use the following commands:
sudo apt remove nodejs
sudo apt remove npm
How to Install Node.js With Apt Using NodeSource
Another way to install Node.js is to use a Personal Package Archive (PPA) repository like NodeSource. Compared to the default Ubuntu repository, NodeSource offers more versions.
This method is ideal if you want to install a specific version or the latest version of Node.js.
Here is how to install Node.js on Ubuntu using the NodeSource repository:
Enter the following commands by pressing Enter after each one:
sudo apt-get update
sudo apt-get upgrade
Skip this step if you already have cURL installed. Otherwise, enter the following command:
sudo apt-get install curl
To install the current version, run the following command. Remember to replace the 18.x value with the Node.js version you prefer:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
Downloading NodeSource with Node.js version 18.x
Once you have the NodeSource repository, install Node.js with the following command:
sudo apt-get install nodejs
Installing Node.js from NodeSource
In addition to Node.js, this command will install NPM along with other dependent packages.
Use these two commands to check the Node.js and NPM versions and confirm that the installation process was successful:
node -v
npm -v
Verifying the newly installed Node.js and NPM versions
How to Install a Specific Version of Node.js Using NVM
Another way to install Node.js on Ubuntu is to use the Node Version Manager (NVM), a bash script used to manage multiple versions of Node.js.
Installing Node.js using the NVM method is ideal if you want to use a specific version. To get started, download and install NVM using wget:
Open the console and use the following command:
sudo apt-get install wget
A terminal window showing the wget installation process
To install a different version, replace v0.39.0 with another value or use the following command to download the latest version:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.39.0/install.sh | bash
Downloading and installing NVM using wget
Allow the NVM script to run from your user's bash profile:
source ~/.profile
Enabling the NVM script for the current user's bash profile
After installing NVM, you can start installing Node.js on your system:
Check all available versions of Node.js with NVM by running the following command:
nvm ls-remote
Listing the available node.js versions using NVM
Pro Tip
Use the keyboard shortcut Ctrl + C to stop the listing process early.
Although you can install any version of Node.js, we recommend using the latest version to ensure compatibility and reliability. In this example, we will install the latest LTS version at the time of writing:
nvm install 16.17.0
Installing a specific version of Node.js using NVM
Verify that it was installed correctly by checking the current active version number:
node -v
Conclusion
Node.js is a server-side JavaScript runtime environment that allows you to build network applications quickly. Web developers frequently use it to handle data-intensive tasks and real-time analytics.
In this article, we reviewed three ways to install Node.js on Ubuntu 22.04 or earlier versions. Before installing Node.js, make sure you can use the sudo command and connect to your virtual private server.
Install the packaged version of Node.js from the Ubuntu repository using Apt. Alternatively, use NodeSource or NVM to install a specific version or the latest LTS version.
We hope this article has helped you understand how to install Node.js on your VPS or local Linux system. If you have any questions, feel free to leave a comment below.
Come chat with us and we will get back to you as soon as possible!
Contact SupportAll the information has been carefully documented and made available in our most recent YouTube tutorial. You can watch it below.
The SkinRestorer plugin can be very useful if you are looking to use your server in non-premium mode. In this case, when configuring it as "online-mode:f
The PHP.ini file is a configuration file that contains your web server's PHP settings. Although it comes preconfigured, you may need to change the default PHP