In this guide, we will walk you through the process of updating Node.js on your RunCloud server using the official NodeSource Node.js Binary Distributions. We will provide step-by-step instructions for both old servers that still use Node.js v14 and new servers deployed after September 27, 2023.
Prerequisites
Before you begin, make sure you have SSH access to your RunCloud server, and that you are logged in as a user with sudo privileges.
In the above screenshot, we can see that our server is using Node.js v14. We will update it to a newer version (e.g., Node.js 16, 18, or 20).
Step 1: Download and Import the NodeSource GPG Key
Run the following commands to download and import the NodeSource GPG key:
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
Step 2: Create the Debian Repository
Choose the Node.js version you want to use (16, 18, or 20) and create the corresponding Debian repository. In this example, we’ll use Node.js v18:
NODE_MAJOR=18
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
You can replace NODE_MAJOR
with your desired Node.js version.
Step 3: Run Update and Install Node.js
Finally, update the package list and install the new Node.js version:
sudo apt-get update
sudo apt-get install nodejs -y
Now you have successfully updated Node.js on your RunCloud server to the desired version. You can verify the installation by running node -v
to check the Node.js version and npm -v
to check the npm version.
Remember to replace the NODE_MAJOR
variable with your desired Node.js version (16, 18, or 20) based on your requirements.