• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

BeginnersBox

How to Guides, Tutorials and Much More

  • Home
  • Tutorials
  • Opinions
You are here: Home / Tutorials / How to Install Node.js on Ubuntu?

How to Install Node.js on Ubuntu?

October 30, 2025 by Sourabh Verma | Updated on: November 28, 2025

Share on Facebook Share on Twitter Share on LinkedIn Share on Reddit Share on WhatsApp Share via Email

As a developer, you all know that JavaScript was developed to run on the client-side for websites. We all know that when a user visits a website, all the JavaScript is downloaded from the server to the client’s device and then executed. This not only consumes the bandwidth but also hampers the performance of the website. The best part of using Node.js is that it’s free, open-source, and developers can use it without learning any new programming language.

Node.js is the one that is developed to run JavaScript on the server side. Making the website’s performance faster also gives power to developers to run JavaScript on the server side itself. Being a cross-platform scripting language, developers can execute the script on both server and client as per the need.

In this tutorial, you will learn

  • How to Install Node.js on Ubuntu
    • Step 1 – Updating the Repository
    • Step 2 – Adding GPG key repository
    • Step 3 – Install Node.js, Yarn, and npm
    • Step 4 – Test and Use Node.js
  • Conclusion

How to Install Node.js on Ubuntu

In this tutorial, we are using the DEB repository to install Node.js on the Ubuntu server. Although you can visit the Node.js official website and download according to the Operating System you are using.

Step 1 – Updating the Repository

The first step before installing Node.js is to update the Ubuntu repository.

# sudo apt update
# sudo apt uprade -y

Step 2 – Adding GPG key repository

The next step is to add the GPG key repository

# sudo apt install curl gnupg ca-certificates -y
# sudo curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | # sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

Now, let’s 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 $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/nodesource.list

# sudo apt update

Step 3 – Install Node.js, Yarn, and npm

The next step is to install Node.js, yarn, and npm. Since we have already added the repository, we just have to execute the commands given below.

# sudo apt install nodejs -y

Let us also install the development tools, which will help us in building native addons

# sudo apt install gcc g++ make -y

Now, let’s install the yarn package manager

# sudo curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | 
# sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# sudo apt update
# sudo apt install yarn -y

Let’s verify the installations

# node -v
v20.19.5
# npm -v
10.8.2
# yarn -v
1.22.22

Step 4 – Test and Use Node.js

The final step is to create a development environment

# cd ~/
# sudo mkdir nodejs-app
# cd nodejs-app

Let’s initialize a project that will contain the metadata about dependencies and apps to run

# sudo npm install express --save

Output
up to date, audited 69 packages in 704ms
16 packages are looking for funding
run  
   'npm fund' for details
found 0 vulnerabilities

Conclusion

With this, you have successfully installed Node.js on Ubuntu. Now you can go ahead and start creating your project

Category: Tutorials Tagged In: linux, Ubuntu

Share on Facebook Share on Twitter Share on LinkedIn Share on Reddit Share on WhatsApp Share via Email

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About Sourabh

Hi, I am Sourabh. With over 12 years of experience in Linux, Windows, servers, databases and other I.T related areas, I make sure to publish easy and well tested tutorials and opinions. I hope you like my work. Thanks

Stay with BeginnersBox

Follow on FacebookFollow on TwitterFollow on LinkedInSubscribe on YouTubeFollow on Instagram Subscribe to RSS Feed

Copyright © 2025 · BeginnersBox · All Rights Reserved.

  • Contact Us
  • Privacy Policy
  • Disclaimer