How to Install NodeJS in Ubuntu Linux Operating System

Posted on

This is an article depicting on the installation process of nodejs in Ubuntu Linux operating system. The tool named ‘node’ based on the manual given which can be looked in the ‘man node’ command, it is describing ‘node’ as the Server-side Javascript. The following is the actual tool located in the operating system where the node or nodejs tool has already been installed :

user@hostname:~$ which node
user@hostname:~$ cd /usr/bin/
user@hostname:/usr/bin$ ls -al | grep node
-rwxr-xr-x  1 root root           943 May 21  2016 dh_nodejs
lrwxrwxrwx  1 root root            43 Jul 30  2014 express -> ../lib/nodejs/express-generator/bin/express
lrwxrwxrwx  1 root root             6 May 21  2016 node -> nodejs
lrwxrwxrwx  1 root root            33 Dec  8  2015 node-gyp -> ../share/node-gyp/bin/node-gyp.js
-rwxr-xr-x  1 root root      11187096 May 21  2016 nodejs
lrwxrwxrwx  1 root root            27 Oct 25  2014 rimraf -> ../lib/nodejs/rimraf/bin.js
lrwxrwxrwx  1 root root            31 Aug 25  2013 semver -> ../lib/nodejs/semver/bin/semver

As shown in the above command, node which is also referred to the actual tool nodejs, showed in the above output in the link represented with the following line :

lrwxrwxrwx  1 root root             6 May 21  2016 node -> nodejs

It is a tool used to execute every Javascript on the Server-side. The above tool is the tool found in the operating system where the installation of the tool itself has already been successfully carried on.

The following is the actual condition when ‘node’ or ‘nodejs’ tool hasn’t been installed :

user@hostname:~$ node
The program 'node' is currently not installed. You can install it by typing:
sudo apt install nodejs-legacy

Switch to ‘root’ account and the start installing nodejs by typing ‘apt-get -y install nodejs-legacy’ :

user@hostname:~$ sudo su -
[sudo] password for user:
root@hostname:~# apt-get -y install nodejs-legacy
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit9 libkadm5srv-mit9
libkdb5-8 libssl-dev libssl-doc
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libuv1 nodejs
The following NEW packages will be installed:
libuv1 nodejs nodejs-legacy
0 upgraded, 3 newly installed, 0 to remove and 28 not upgraded.
Need to get 3.246 kB of archives.
After this operation, 13,5 MB of additional disk space will be used.
Get:1 xenial/universe amd64 libuv1 amd64 1.8.0-1 [57,4 kB]
Get:2 xenial-updates/universe amd64 nodejs amd64 4.2.6~dfsg-1ubuntu4.1 [3.161 kB]
Get:3 xenial-updates/universe amd64 nodejs-legacy all 4.2.6~dfsg-1ubuntu4.1 [27,7 kB]
Fetched 3.246 kB in 2min 20s (23,1 kB/s)
Selecting previously unselected package libuv1:amd64.
(Reading database ... 404504 files and directories currently installed.)
Preparing to unpack .../libuv1_1.8.0-1_amd64.deb ...
Unpacking libuv1:amd64 (1.8.0-1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_4.2.6~dfsg-1ubuntu4.1_amd64.deb ...
Unpacking nodejs (4.2.6~dfsg-1ubuntu4.1) ...
Selecting previously unselected package nodejs-legacy.
Preparing to unpack .../nodejs-legacy_4.2.6~dfsg-1ubuntu4.1_all.deb ...
Unpacking nodejs-legacy (4.2.6~dfsg-1ubuntu4.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for doc-base (0.10.7) ...
Processing 1 added doc-base file...
Processing triggers for man-db (2.7.5-1) ...
Setting up libuv1:amd64 (1.8.0-1) ...
Setting up nodejs (4.2.6~dfsg-1ubuntu4.1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Setting up nodejs-legacy (4.2.6~dfsg-1ubuntu4.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...

The above output command generated showing the result that ‘node’ or ‘nodejs’ tool has been successfully installed. Just execute the ‘node’ or ‘nodejs’ command as shown below :

user@hostname:/usr/bin$ node
> .exit
user@hostname:/usr/bin$ nodejs
> .exit

The above is the execution of the ‘node’ or ‘nodejs’ to enter the node or nodejs command prompt. To quit from the node or nodejs command prompt, just type ‘.exit’.

Leave a Reply