Today we will try to give a
clear and concise explanation of how to install Node.js on Windows
, which I hope will serve the newest users as a contact with Node.js.
The objective of this explanatory guide will be to get a fully configured Node.js environment ready to work in the Windows operating system.
What is Node.js?
Answering the question of what is Node.js should be our first step
, to have at least an idea that we are installing in our system.
We can define Node.js in a simple way, as a Javascript interpreter that works on the server side. Until now we knew Javascript because it was running on the client side, usually in our browsers, but
with Node.js we have all the potential of Javascript on the server side
.
Node.js includes the Javascript interpreter named V8, whose development is in charge of Google.
How to install Node.js on Windows?
The easiest way to install Node.js on Windows is to use the installer available on the official website
:
https://nodejs.org/en/download/
We see in our browser that we are offered several options and we will try to clarify which version we should choose. First we see that we can select between:
-
LTS
(recommended for most users)
: it is the version of Node.js with Long Term Support (LTS), that is, the one that is given long-term support. This version may
not have
available the latest technologies that are not yet considered stable.
-
Current
: This is the most recent version of Node.js and includes all the functionalities, even those that are newer and are not considered stable.
As a general rule, selecting the LTS version is the recommended and stable option.
As for the installation packages in Windows we have:
-
Windows Installer
(.msi)
: is an installer with an
.msi
extension that will automate the entire installation process, adding system variables automatically and also includes the Node.js module manager known as NPM (Node Package Manager) .
-
Windows Binary
(.exe)
: With this option we will download only the Node.js executable, which does not include NPM.
The recommended option is to download the .msi installer, since it is the most complete and also automatically configures our system.
Finally, we can only select between 32-bit or 64-bit technology depending on our Windows operating system.
Once installed, we will prove that everything works correctly, for this
we open the command console
and execute the
node
command. If everything went well, we will be inside the Node.js console and we can execute the following line of code:
console.log("hola mundo");
To exit the Node.js console we can press the key combination
Ctrl + C
twice in a row or simply type
.exit
and press
Enter
.
How to install a module with NPM on Windows?
Now that we have Node.js installed, we surely need to install some module or package, for this we will use the NPM manager
(Node Packahe manager)
.
We go to the Windows command console and execute the
npm
command, we see that it shows us a message saying that the use is
npm <command>
, but we do not run so much, since
if the terminal that we are running in Windows does not have Administrator permissions will surely fail the module installation process
, so we must open a terminal with administrator permissions as explained
in this link
.
Now we execute the following command that allows us to search for packages. As an example, we will look for the “gulp-uglify” package with the
npm search gulp-uglify
and we will see that all the related packages are shown on the screen.
The first time we run a search in NPM it usually takes a long time, since it takes to create the package index.
To install the module with NPM the command would be:
npm install gulp-uglify
And this is it, we are ready to develop applications under Node.Js in Windows.