How To Install Node JS on Ubuntu 20.04 LTS

On this article we will discuss how to install Node Js and npm on Ubuntu 20.04 LTS Operating system.

Introduction

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment for server-side programming. Shortly, Node.Js enables executing JavaScript code outside a web browser. Node.js allows developers to create scalable backend functionality using JavaScript and producing dynamic web page content before the page is sent to the user’s web browser. Node.js is using Google’s V8 JavaScript engine to interpret JavaScript which was developed by Ryan Dahl in 2009. NPM (Node Package Manager) is the default package manager for Node.js which helps developers share and reuse their code. On this article we will discuss how to install Node.js on Ubuntu 20.04 LTS.

Node.Js Installation On Ubuntu 20.04 LTS

There are at least 3 options to install Node.Js, namely:

  • Install Node.js and npm from the Ubuntu repository
  • Install Node.js and npm using NVM
  • Install Node.js and npm from NodeSource

On this article, we will choose to Install Node.js and npm from NodeSource. There are several stages of installing Node.js and will be explained below.

1. Download Node.Js Source

At this stage we will add Node.js repostory version 14.x repository to Ubuntu 20.04 LTS. By using curl command line, we wil execute this task.

ramans@otodiginet:~$ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
Installing the NodeSource Node.js 14.x repo…
 Populating apt-get cache…
 apt-get update
 Hit:1 http://mirror.telkomuniversity.ac.id/ubuntu focal InRelease
 Hit:2 http://mirror.telkomuniversity.ac.id/ubuntu focal-updates InRelease                           
 Hit:3 http://mirror.telkomuniversity.ac.id/ubuntu focal-backports InRelease                         
 Hit:4 http://mirror.telkomuniversity.ac.id/ubuntu focal-security InRelease                          
 Hit:6 http://ppa.launchpad.net/teejee2008/ppa/ubuntu focal InRelease                                
 Hit:8 http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu focal InRelease                      
 Hit:5 https://downloads.apache.org/cassandra/debian 40x InRelease                                   
 Hit:7 https://downloads.apache.org/cassandra/debian 311x InRelease
 Hit:9 https://packagecloud.io/sensu/stable/ubuntu focal InRelease
 Reading package lists… Done 
 Confirming "focal" is supported…
 curl -sLf -o /dev/null 'https://deb.nodesource.com/node_14.x/dists/focal/Release' 
Node.Js Repository
Node.Js Repository

2. Install Node.Js

After Node.Js repository was added, then we install Node.js by submitting command line : sudo apt install nodejs.

ramans@otodiginet:~$ sudo apt install nodejs
 Reading package lists… Done
 Building dependency tree       
 Reading state information… Done
 The following NEW packages will be installed:
   nodejs
 0 upgraded, 1 newly installed, 0 to remove and 106 not upgraded.
 Need to get 24.6 MB of archives.
 After this operation, 119 MB of additional disk space will be used.
 Get:1 https://deb.nodesource.com/node_14.x focal/main amd64 nodejs amd64 14.16.1-deb-1nodesource1 [24.6 MB]
 Fetched 24.6 MB in 15s (1,591 kB/s)                                                                        
 Selecting previously unselected package nodejs.
 (Reading database … 196168 files and directories currently installed.)
 Preparing to unpack …/nodejs_14.16.1-deb-1nodesource1_amd64.deb …
 Unpacking nodejs (14.16.1-deb-1nodesource1) …
 Setting up nodejs (14.16.1-deb-1nodesource1) …
 Processing triggers for man-db (2.9.1-1) …
Node.Js Installation on Ubuntu 20.04 LTS
Node.Js Installation on Ubuntu 20.04 LTS

3. Verifying Node.Js

After installation was completed done, the next step is to verify Node.Js by querying its version. This task can be done by submitting command line : node --version and npm --version. The result is as shown below.

ramans@otodiginet:~$ node --version
 v14.16.1
 ramans@otodiginet:~$ npm --version
 6.14.12
 ramans@otodiginet:~$ 
Node.Js and npm version
Node.Js and npm version

Conclusion

The Node JS installation on Ubuntu 20.04 LTS using Node.JS source has been done successfully. The newest Node.JS information can be found at nodejs.org official website.

Share this article via :

Leave a Reply

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