How to Install Node.js 12 on Ubuntu 19.04

Installation Node.js 12 On Ubuntu 19.04

Installation process

Check the Ubuntu version by using the following command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 19.04
Release:	19.04
Codename:	disco

Update the repository by use the following command.

root@linuxhelp:~# apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu disco InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu disco-updates InRelease [97.5 kB]
Get:3 http://security.ubuntu.com/ubuntu disco-security InRelease [97.5 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu disco-backports InRelease [88.8 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu disco-updates/main i386 Packages [135 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu disco-updates/main amd64 Packages [150 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu disco-updates/main Translation-en [58.6 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu disco-updates/main amd64 DEP-11 Metadata [82.0 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu disco-updates/main DEP-11 48x48 Icons [13.5 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu disco-updates/main DEP-11 64x64 Icons [22.4 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu disco-updates/main amd64 c-n-f Metadata [2,996 B]
.
.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
153 packages can be upgraded. Run 'apt list --upgradable' to see them.

Install the curl package by using the following command

root@linuxhelp:~# apt install curl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libcurl4
The following NEW packages will be installed:
  curl
The following packages will be upgraded:
  libcurl4
1 upgraded, 1 newly installed, 0 to remove and 152 not upgraded.
Need to get 399 kB of archives.
After this operation, 412 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
.
.
Setting up libcurl4:amd64 (7.64.0-2ubuntu1.1) ...
Setting up curl (7.64.0-2ubuntu1.1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.29-0ubuntu2) ...

Download the node packages. Use the Following command

root@linuxhelp:~# curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

##Installing the NodeSource Node.js 12.x repo...
## Populating apt-get cache...

+ apt-get update
Hit:1 http://security.ubuntu.com/ubuntu disco-security InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu disco InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu disco-updates InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu disco-backports InRelease
Reading package lists... Done
.
.
+ apt-get update
Hit:1 http://security.ubuntu.com/ubuntu disco-security InRelease
Get:2 https://deb.nodesource.com/node_12.x disco InRelease [4,583 B]      
Hit:3 http://in.archive.ubuntu.com/ubuntu disco InRelease                 
Get:4 https://deb.nodesource.com/node_12.x disco/main amd64 Packages [765 B]
Hit:5 http://in.archive.ubuntu.com/ubuntu disco-updates InRelease
Hit:6 http://in.archive.ubuntu.com/ubuntu disco-backports InRelease
Fetched 5,348 B in 1s (3,976 B/s)
Reading package lists... Done

## Run `sudo apt-get install -y nodejs` to install Node.js 12.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
     echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn

Install the node packages. You can use the following command

root@linuxhelp:~# apt install nodejs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython-stdlib libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python python-minimal python2
  python2-minimal python2.7 python2.7-minimal
Suggested packages:
  python-doc python-tk python2-doc python2.7-doc binfmt-support
The following NEW packages will be installed:
  libpython-stdlib libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib nodejs python python-minimal
  python2 python2-minimal python2.7 python2.7-minimal
0 upgraded, 11 newly installed, 0 to remove and 152 not upgraded.
Need to get 20.6 MB of archives.
After this operation, 97.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
.
.
.
Unpacking nodejs (12.4.0-1nodesource1) ...
Setting up nodejs (12.4.0-1nodesource1) ...
Setting up libpython2.7-stdlib:amd64 (2.7.16-2) ...
Setting up python2.7 (2.7.16-2) ...
Setting up libpython2-stdlib:amd64 (2.7.16-1) ...
Setting up python2 (2.7.16-1) ...
Setting up libpython-stdlib:amd64 (2.7.16-1) ...
Setting up python (2.7.16-1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for gnome-menus (3.32.0-1ubuntu1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for desktop-file-utils (0.23-4ubuntu1) ...

To Find the version of node by using the following command

root@linuxhelp:~# node -v
v12.4.0

With this The method to install Node.js 12 on centos7.6 comes to an end.

Tag : Node.js Ubuntu
FAQ
Q
What is Node.js?
A
Node.js is a server side scripting based on Google’s V8 JavaScript engine
Q
Where can you use Node.js?
A
Node.js is used to build scalable programs especially web applications which are computationally simple but are frequently accessed
Q
What are the features of Node.js?
A
Node.js is a single-threaded but highly scalable system that utilizes JavaScript as its scripting language
Q
What is the difference between Node.js and Ajax?
A
Node.js and Ajax (Asynchronous JavaScript and XML) are the advanced implementation of JavaScript. They all serve completely different purposes.


Ajax is primarily designed for dynamically updating a particular section of a page’s content, without having to update the entire page.

Node.js is used for developing client-server applications.
Q
What are the functionalities of NPM in Node.js?
A
NPM (Node package Manager) provides two functionalities:

-Online repository for Node.js packages
-Command line utility for installing packages, version management and dependency management of Node.js packages