Member-only story
How to Install Node.js on Ubuntu: Three Easy Methods for 2024 Explained

Node.js is a powerful JavaScript runtime that allows you to run JavaScript code outside of a web browser, making it perfect for building scalable server-side applications. In this guide, we’ll show you three different methods to install Node.js on Ubuntu, so you can choose the one that best fits your needs.
Method 1: Installing Node.js Using apt (Default Method)
This method installs Node.js directly from Ubuntu’s default repositories. While this is the simplest way to get Node.js up and running, be aware that it might install an older version.
1. Update your package list to ensure you have the latest information on available packages:
sudo apt update
2. Install Node.js from the default Ubuntu repositories:
sudo apt install nodejs
3. Install npm (the Node.js package manager):
sudo apt install npm
4. Verify the installation by checking the version of Node.js and npm:
node -v
npm --version
Note: If you require a specific or newer version of Node.js, consider using the other methods described below.