11 C
Texas
angeloma
Senior Writer and partner

How to install Nodejs on Ubuntu 18.04 LTS / Ubuntu 19.04?

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!!

- Advertisement -

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.

sudo apt update && sudo apt upgrade

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

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

sudo apt install nodejs

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:

sudo apt install npm

3.- Installing npm
3.- Installing npm

Finally we can consult the installed version of node.js

nodejs -v

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:

cd ~
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

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:

sudo apt install nodejs

And finally we check the installed version.

nodejs -v

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.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

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:

source ~/.profile

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

Now we can install different versions of node.js

nvm ls-remote

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

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

nvm install 10.15.3

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.

node -v

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.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article