Install Nodejs on Ubuntu

Node.js is an asynchronous event-driven JavaScript runtime built on Chrome’s V8 JavaScript engine. It runs at the server-side. It mainly used for easily building fast and scalable network applications. In this article, you will find ways to install Nodejs on Ubuntu Linux.

In this tutorial, we will install the node.js in Ubuntu using two different ways. The first method is by using Ubuntu’s Official repository and second is by using the nodesource repository.

Nodejs latest version

At the time of writing this article, the latest version of the nodejs is 13. But we will install the LTS version of nodejs which is version 12. However, if we install the nodejs using Ubuntu’s Official repository, then we will not get the latest version of nodejs.

Official repository of Ubuntu 18.04 LTS is having nodejs version 8.10 and Ubuntu 16.04 LTS is having version 4.2. However, if you want to install the latest version or the LTS version of nodejs then you have to use the nodesource repository.

Install Nodejs on Ubuntu using Official repository

For this tutorial, we are using Ubuntu 18.04. However, you can follow the same steps for other versions of Ubuntu.

  • Step 1: Open your terminal and update the repository with the latest package information. Use the below command to update the Ubuntu Repository.
sudo apt-get update
apt-get update image
  • Step 2: After that, Install the nodejs package using the below command.
sudo apt-get install nodejs
install nodejs on ubuntu
  • Step 3: After installing, you can verify the installation by checking nodejs version. Use the below command to verify the installation.
node -v
####OR####
node --version
verify nodejs install

Install Nodejs using nodesource repository

We can install the latest version of Nodejs using nodesource repository. But for this tutorial, we will install the LTS version of nodejs which is version 12 at this time. So let’s begin with the first step, which is updating the source repository.

  • Step 1: Same as the previous method, we update or repository by using the below command.
sudo apt-get update
  • Step 2: After that, we have to add the nodesource PPA by running the below command.
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
adding nodesource ppa

Now the packages of nodejs version 12 are available on our Ubuntu machine.

  • Step 3: After that, install the nodejs package by running the below command.
sudo apt-get install nodejs
install latest nodejs on ubuntu
  • Step 4: After installing, verify the installation by running the below command.
node -v
###OR###
node --version
verify latest nodejs install
  • Note: As many users search for How to install npm on Ubuntu. I would like to tell you that when we install nodejs the npm will be installed along with it. You can also verify the installation of npm using the below command.
npm -v
###OR###
npm --version
verify npn install

Summary :

In the end, Now we have nodejs and npm installed on Ubuntu. You can share your thoughts in the comment section.

You may also like...

Leave a Reply

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