How to install Nodejs on Ubuntu 18.04 LTS / Linux Mint 19?

0
1187
nodejs

If you’re a developer or just starting out in that world, you’ve probably heard of node.js, this fantastic platform built on Chrome’s JavaScript interpreter to quickly and easily build scalable network applications. It runs on the server side, and thus allows the server and desktop applications to communicate via Javascript.

Thanks to its simplicity and ease of use, node.js is reaching great levels of popularity and is even positioned as a direct rival to PHP.

Node.JS has its own server and maintains a single instance of it, this means a much more efficient use of resources and a much faster response to simultaneous connections. It is multiplatform allowing its installation in almost any operating system in pc.

For this tutorial we will use Ubuntu 18.04 to install node.js.

3 ways to reach the goal!!

There are three ways to install node.js. The choice will depend on your level of knowledge and what you really want for your computer. The options are 3: use the official repositories o ubuntu, use the external PPA or install it via NVM.

1.- Using the official Ubuntu repositories

This method is safer, more stable and easier but does not provide the flexibility that many would like. This is because over time the installed version could be considered obsolete.

First we must open a terminal. Then we proceed to update the system in order to have the latest security patches.

1.- Upgrading the system
1.- Upgrading the system

Next we proceed to install node.js from the official repositories with:

2.- Installing node.js
2.- Installing node.js

This will install node.js. However, in many cases you need your NPM package manager which is not installed by default with this method. For this we write:

3.- Installing npm
3.- Installing npm

Finally we can consult the installed version of node.js

4.- checking the installed version
4.- checking the installed version

2.- Using PPA

For more recent versions of node.js we usually use this installation method. Recent versions of node.js provide us with security updates as well as more improvements than ever before. If you have installed node.js before, you must uninstall it.

First we must add the repository in question. To do this in a terminal, we write:

In this case we chose version 10.x because it is a higher version than the official repositories, but you can check the rest of the versions supported by the PPA here

5.- Using a ppa for installing node.js
5.- Using a ppa for installing node.js

Then we proceed to install it:

And finally we check the installed version.

6.- Nodejs installed
6.- Nodejs installed

With this method, there is no need to install npm separately. In addition we install a higher version of node.js

3.- Installing node.js using NVM

Using NVM we can have more flexibility to install node.js because we can choose which version to install from a quick and easy way.

First we can check on your github page that we can download NVM in two ways, using wget or curl. We’ll use curl.

7.- Getting nvm
7.- Getting NVM

At the end of the installation, you will create a hidden nvm folder. Now to use nvm we must do:

8.- source profile file
8.- source profile file

Now we can install different versions of node.js

9.- Showing nvm list
9.- Showing nvm list

We will install the latest stable version:We will install the latest stable version:

10.- Installing the lastest version of node.js
10.- Installing the lastest version of node.js

With the command above we also install the npm.

We proceed to verify the installed version.

11.- nodejs version installed
11.- nodejs version installed

As a conclusion we can say that node.js is a very popular implementation in the field of web development, and its installation is really easy in Ubuntu 18.04 which in turn is a GNU/LINUX distribution widely used by developers around the world.

Please share this article on your social networks.

Spread the love
  • 8
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here