Installing Node.js on Ubuntu VPS with GreatHost π
Introduction to Installing Node.js on Ubuntu with GreatHost π
To get started with Node.js on your Ubuntu server hosted by GreatHost, you'll need to install it first. This guide will walk you through three different methods: using apt from the default repositories, using a NodeSource PPA, and using the Node Version Manager (nvm) π οΈ.
Prerequisites
Before you begin, ensure you have a non-root user account with sudo privileges set up on your GreatHost Ubuntu server. You can learn how to do this by following the Ubuntu initial server setup tutorial.
Option 1 β Installing Node.js with Apt from the Default Repositories
Ubuntu 24.04 contains a version of Node.js in its default repositories. At the time of writing, the version in the repositories is v24.x. To install, first refresh your local package index:
sudo apt updateThen, install Node.js:
sudo apt install nodejsCheck that the install was successful by querying node for its version number:
node -vIf the package in the repositories suits your needs, this is all you need to do to get set up with Node.js. In most cases, youβll also want npm, the Node.js package manager. On some Ubuntu versions, npm is installed automatically with nodejs. If it is missing, you can install it separately with apt:
sudo apt install npmOption 2 β Installing Node.js with Apt Using a NodeSource PPA
To install a different version of Node.js, you can use a PPA (personal package archive) maintained by NodeSource. First, install the PPA to get access to its packages:
cd ~
curl -sL https://deb.nodesource.com/setup_25.x -o /tmp/nodesource_setup.shInspect the contents of the downloaded script with nano or your preferred text editor, then run the script with sudo:
sudo bash /tmp/nodesource_setup.shNow, you can install the Node.js package:
sudo apt install nodejsVerify that youβve installed the new version by running node with the -v version flag:
node -vOption 3 β Installing Node Using the Node Version Manager
Another way of installing Node.js is to use nvm, the Node Version Manager. To install nvm on your Ubuntu machine, visit the projectβs GitHub page and copy the curl command from the README file. Before piping the command through to bash, audit the script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.shWhen you are satisfied, run the command again with | bash appended at the end:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bashThis will install the nvm script to your user account. To use it, you must first source your .bashrc file:
source ~/.bashrcNow, you can ask nvm which versions of Node are available:
nvm list-remoteInstall a version of Node by writing in any of the release versions listed. For instance, to get version v24.13.0, you can run:
nvm install v24.13.0Removing Node.js
You can uninstall Node.js using apt or nvm, depending on how it was installed. To remove the version from the system repositories, use apt remove:
sudo apt remove nodejsTo uninstall a version of Node.js that you installed using nvm, first determine whether it is the current active version:
nvm currentIf the version you are targeting is not the current active version, you can run:
nvm uninstall node_versionConclusion
By following this guide, you've successfully installed Node.js on your Ubuntu server hosted by GreatHost using one of three methods: apt from the default repositories, a NodeSource PPA, or the Node Version Manager (nvm). You can now start developing your Node.js applications π.