Logo

How to Install Node.js on Ubuntu 24.04

Mar 17, 2024

To install Node.js on Ubuntu 24.04, follow the steps below:

Step 1 : Update the package repository.

sudo apt update

Step 2 : Install the required packages: ca-certificates, curl, and gnupg.

sudo apt install ca-certificates curl gnupg

Step 3 : Import the GPG key for the Node.js repository.

curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

Step 4 : Add the Node.js repository.

NODE_MAJOR=20
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

Step 5 : Update the package list again.

sudo apt update

Step 6 : Install Node.js and npm.

sudo apt install nodejs

Step 7 : Verify the installation.

node -v
npm -v

Congratulations! You have successfully installed Node.js and npm on your Ubuntu 24.04 system.

Recommended