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.
Open your terminal and run the following command to refresh your local package index:
sudo apt update
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)
Run the standard installation command via apt:
sudo apt-get install -y nodejs
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!
