How To Install Node.js on Debian Server

In this tutorial, we will discuss how to install Node.js on a Debian cloud

Install Using a PPA

The fastest and simplest approach to get the latest version of Node.js on your cloud server is to include the personal package archive (PPA ) kept up by NodeSource. This will have more most recent versions of Node.js than the authority Debian repositories. It likewise gives you a chance to pick between Node.js v4.x and v6.x, and Node.js v7.x  the most recent version.

To begin with, install the PPA keeping in mind the end goal to gain access to its contents. Ensure you are in your home directory, and utilize curl to recover the installation content for your favored version, trying to replace 6.x with the right form string:

$ cd ~

$ curl -sL -o


You can examine the substance of this script with nano  or with any other text editor tool:

$ nano

What's more, run the content under sudo:

$ sudo bash

The PPA will be prefixed to your configuration and your local bundle cache will be refreshed naturally. In the wake of running the setup content from nodesource, you can easily install the Node.js bundle similarly that you did above:

$ sudo apt-get install nodejs

The nodejs bundle contains the nodejs binary and also npm, so you don't have to install npm independently. Be that as it may, all together for some npm bundles to work, you should install the fundamental package:

$ sudo apt-get install build-essential

Install Using nvm

An additional option to installing Node.js via apt  is to utilize a uniquely outlined tool called nvm, be an abbreviation of Node.js version manager. Utilizing nvm, you can install different, independent versions of Node.js which will enable you to control your environment simpler. It will give you on-request access to the most up to date versions of Node.js, yet will likewise enable you to target past discharges that your application may rely upon.

$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev


Once the essential packages are installed, you can take down the nvm installation script from the venture's GitHub page. The version number might be unique, however when all is said in done, you can easily download it with curl:

$ curl -sL -o

What's more, assess the installation script with nano:

$ nano

Run the script using bash:

$ bash

It is going to install the software into a subdirectory of your home catalog at ~/.nvm. It will likewise add the vital lines to your ~/.profile file to make the nvm command accessible.

To access the nvm command and its usefulness, you'll have to log out and log back in once more, or you can source the ~/.profile document with the goal that your present session knows about the modifications:

$ source ~/.profile

Since you have nvm installed, you can install detached Node.js versions.

To discover the versions of Node.js that are accessible for installation, you can enter:

$ nvm ls-remote




As should be see, the most recent version available at the season of this written work is v7.2.0, however v6.9.2 is the most recent long haul support release. You can install that by writing:

$ nvm install 6.9.2

You will see the following result:


Computing checksum with sha256sum
Checksums matched!
Now utilizing node v6.9.2 (npm v3.10.9)
Creating default alias: default -> 6.9.2 (-> v6.9.2)

More often, nvm will change to utilize the most recently installed  version. You can unequivocally advise nvm to utilize the version we just downloaded by writing:

$ nvm use 6.9.2

You can see the version as of now being utilized by the shell by composing:

$ node -v



On the off chance that you have various Node.js versions, you can see which ones are installed by writing:

$ nvm ls

If you want to make any of the versions the default version, you can enter the following:

$ nvm alias default 6.9.2

This version 6.9.2 will be consequently chosen when you open another terminal session. You can likewise reference it by the alias like this:

$ nvm use default

Every version of Node.js will monitor its own particular packages and has npm accessible to deal with these.

You can have npm install bundles to the Node.js project's ./node_modules index by utilizing the ordinary arrangement. For instance, for the express module:

$ npm install express

In the event that you'd get a kick out of the chance to install it internationally, you can include the - g flag:

$ npm install -g express

The above command will install the package in:

$ ~/.nvm/node_version/lib/node_modules/package_name

Installing all inclusive will give you a chance to run the commands from the commands line, however you'll need to connect the package into your local circle to require it from inside a program:

$ npm link express

You can find out more about the choices available to you with nvm by entering:

$ nvm help