Guides and tutorials

Hundreds of tutorials and step by step guides carefully written by our support team.

How to install and configure a Node JS evironment

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.

1. We update the list of packages

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 update

2. Download and install nodejs and npm using the package manager

Next, we must install these two packages: nodejs and npm. Nodejs refers to the runtime environment that will allow us to execute code written in Javascript on the server. On the other hand, npm is the acronym of the "Node Packet Manager". We will use npm to install, manage and remove Node JS packages and libraries.

apt-get install nodejs npm

3. We verify the installation

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:

nodejs --version npm --version

If these commands run without error and show us the version of the installation, then we will have correctly installed nodejs and npm.

4. Run your first Javascript program on the server with Node JS

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.

nano programa.js

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:

node programa.js

It is done!

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.

More than 2000 m² of own facilities and Data Centers in Spain
Your privacy is important for us
We use our own cookies for the proper functioning of the site. In addition, third-party cookies are used for analytical purposes only. This information is not associated with any person so that personal identifying data is not stored, but is only information that is collected to identify the session, with the aim of facilitating the analysis of the website. You can change your preferences at any time by entering this website again. For more information about our cookie policy you can visit our Cookies. You can press the "Accept and close" button to give us your consent or you can access more detailed information and manage cookies.
More than 2000 m² of own facilities and Data Centers in Spain
Your privacy is important for us
We use our own cookies for the proper functioning of the site. In addition, third-party cookies are used for analytical purposes only. This information is not associated with any person so that personal identifying data is not stored, but is only information that is collected to identify the session, with the aim of facilitating the analysis of the website. You can change your preferences at any time by entering this website again. For more information about our cookie policy you can visit our Cookies. You can press the "Accept and close" button to give us your consent or you can access more detailed information and manage cookies.