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.
sudo apt update && sudo apt upgrade
Next we proceed to install node.js from the official repositories with:
sudo apt install nodejs
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
Finally we can consult the installed version of node.js
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
Then we proceed to install it:
sudo apt install nodejs
And finally we check the installed version.
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
At the end of the installation, you will create a hidden nvm folder. Now to use nvm we must do:
Now we can install different versions of node.js
We will install the latest stable version:We will install the latest stable version:
nvm install 10.15.3
With the command above we also install the npm.
We proceed to verify the installed version.
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.