In this manual, we will teach you how to easily install a Node JS environment that has both Node and the "NPM" package manager, one of the fundamental components of any Node JS environment.
Please, remember that this manual has been written, specifically, for the distribution and version Ubuntu 18.04. The steps could change for other versions or distributions, although they should be very similar for those distributions based on Debian.
We use the "apt-get update" command to update the list of packages and ensure that we always download the latest version of the available packages.
apt-get install nodejs npm
To verify the installation, we will check both the version of nodejs and the one of npm. We will do it with the following commands:
If these commands run without error and show us the version of the installation, then we will have correctly installed nodejs and npm.
Finally, we will create a small "Hello World" program to demonstrate the functioning of Node JS. First of all, we will create a text file, for example, with the 'nano' editor.
Then copy and paste the code that we show you below:
console.log ("Hello, world!");
Save the file with the key combination
CTRL + O and finally execute the program as follows:
If you have correctly followed the steps in this tutorial, you will have successfully installed Node JS and NPM, as well as writing a small "Hello World" program to verify its operation.