What is Node.js?
How to install Node.js
You can download the correct installer for your system from the nodejs.org site.
You can choose between the current edition or the LTS edition.
LTS stands for long term support: it has a longer maintenance cycle than the current edition which makes it ideal for production use.
On the other side the current edition has the most up to date version and the latest features.
For the more adventurous there are nightly builds.
Installing Node.js in Debian linux
If you are using a Linux distribution, chances are that there is already a Node.js package in your distribution’s repository. In Debian Linux installing Node.js is as simple as running this command:
apt-get install nodejs
Still, the nodejs package in the official Debian repositories is usually quite old and out of date.
You can follow these steps to install a newer version:
1. Install the NodeSource repo
curl -sL https://deb.nodesource.com/setup_9.x | bash -
2. Install node ( this will also install npm)
apt-get install -y nodejs
3. Install build-essential
apt-get install -y build-essential
Check your node version
If everything has gone as expected, you should have now Node.js installed in your system; you can check the Node.js version like this:
Usually you would use the node -v command to check the node version, but in Debian there’s already a different package, also called “node”, therefore to avoid conflicts the Node.js command was renamed to “nodejs”.
The installation of Node.js includes also npm, the Node.js package manager: npm helps developers to keep tabs on the modules (reusable pieces of code) used in their projects. You can think of it as the apt-get/yum/pacman, etc equivalent for Node.js.
Since npm is updated more frequently than Node.js, you may not have the most recent version, even if you installed the current edition of Node.js.
Let’s check which version of npm we have installed in our system:
And let’s run this command to update npm to the last version:
npm install npm@latest -g
Use Node REPL
A last test to run to check that everything has installed correctly is to run Node.js REPL. Just run the node command from the console:
That’s all, I hope it was helpful 🙂