How to install Node.JS on Linux-Ubuntu Servers

Here is a simple, step-by-step guide to installing Node.js on Ubuntu/Linux using the official NodeSource repository, which ensures you get a modern and stable version.

 

1. Update your package list:

Ensure your system package cache is up to date.

Open your terminal and run the following command to refresh your local package index:

sudo apt update

 

2. Add the NodeSource repository:
 
Required to get a recent LTS version of Node.js.

 

Download and execute the official NodeSource setup script for the latest Long Term Support (LTS) release:

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

(Note: If your system doesn't have curl installed, you can install it first with sudo apt install curl)

3. Install Node.js and npm:
 
This installs both the runtime and the Node Package Manager.

 

Run the standard installation command via apt:

sudo apt-get install -y nodejs

 

4. Verify the installation:
 
Check that both Node.js and npm are working properly.

 

Run the following commands to check their installed versions:

node -v
npm -v

 

If version numbers (such as v20.x.x or higher) are displayed, Node.js and npm are successfully installed and ready to use!

HostWinds VPS