Node.js 20 is the current Long-Term Support (LTS) release, offering improved performance, the experimental Permissions Model, and a stable test runner. This guide installs Node.js 20 LTS on Ubuntu 24.04 LTS using the official NodeSource repository.
Tested and valid on:
- Ubuntu 24.04 LTS
Prerequisites
- Ubuntu 24.04 LTS server
- A user with sudo privileges
Step 1 – Add the NodeSource Repository
Download and run the NodeSource setup script for Node.js 20:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
Step 2 – Install Node.js
Install from the NodeSource repo:
sudo apt install nodejs -y
Step 3 – Verify the Installation
Check Node.js and npm versions:
node --version
npm --version
Step 4 – Update npm to the Latest Version
The bundled npm may not be the latest:
sudo npm install -g npm@latest
Step 5 – Install Build Tools
Some npm packages require native compilation:
sudo apt install build-essential -y
Step 6 – Test Node.js
Create a simple test script:
echo "console.log('Node.js ' + process.version + ' running on Ubuntu 24.04')" > test.js
node test.js
Step 7 – Install Yarn (optional)
Install Yarn as an alternative package manager:
sudo npm install -g yarn
yarn --version
Conclusion
Node.js 20 LTS is now installed on Ubuntu 24.04 LTS. Use it to run JavaScript on the server, build REST APIs with Express.js, or create real-time applications with Socket.IO.