How to install Node.js on Debian 8

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@aser1111·
0.000 HBD
How to install Node.js on Debian 8
an introduction
Node.js is a multi-purpose scripting platform that allows users to build network applications quickly. By using JavaScript on both the front and back interfaces, the development will be more consistent and designed within the system itself. 
Debian 8 has a version of Node.js in its default folders, but that version is probably outdated.

![](https://steemitimages.com/DQmV2Ekv9e4wUffiHTZKZQQJ2cVWjyBJ6qnMeVG5T3PzRQZ/image.png)
Basic requirements
To continue this lesson, you will need a Debian 8 server with a non-root user and privileges sudo.

How to install using PPA
The fastest and easiest way to get the latest version of Node.js on your server is by adding NodeSource's PPA (personal package archive). Will include more Node.js updates than official Debian repositories. It also allows you to choose between Node.js v4.x (old version supported long term, supported until April 2017), v6.x (newer version of LTS, which will support until April 2018), and Node.js v7.x ( Current version under development). 
First, install the PPA to obtain its contents. Make sure you are in the home directory, use curlthe script to install your preferred version, and replace 6.x with the correct version number:

cd ~ 
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
You can examine the contents of this script by nano(or your favorite text editor):

nano nodesource_setup.sh
Run the script after the command sudo:

sudo bash nodesource_setup.sh
PPA will be added to your settings and your local stored package will be updated automatically. After running the installation program from nodesource, you can install the Node.js package in the same way as above:

sudo apt-get install nodejs
The nodejs package contains nodejs (nodejs binary) normalization npm, so you do not need to install npmseparately. But for some packages to work npm(such as those that require code translation from the source), you will need to install the package build-essential:

sudo apt-get install build-essential
How to install by nvm
Instead of installing Node.js apt, you can use a special tool called nvm (Node.js version manager). Using nvm, you can install multiple integrated versions of Node.js which will allow you to set the working environment easier. It will also give you access to the latest versions of Node.js, but will also allow you to target previous versions that your app may rely on. 
Initially we will need to get software packages from Debian repositories which will allow us to build source packages. The instruction nvmwill use those tools to build the necessary components:

sudo apt-get update 
sudo apt-get install build-essential libssl-dev
Once the necessary packages are installed, you can delete the installation script nvmfrom the project page on GitHub , the version number may be different, but in general, you can load it with curl:

curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh -o install_nvm.sh
See the installation script by nano:

nano install_nvm.sh
Run the script by bash:

bash install_nvm.sh
The script will install the program in a folder in ~/.nvm. It will also add the necessary lines to the file ~/.profileto make the instruction nvmavailable. 
To gain access to the instruction nvmas well as its functionality, you will need to log off and sign in again, or you can add the source ~/.profileuntil changes are considered in the current session:

source ~ / .profile
Now that nvmyou have installed , you can install one of the Node.js versions separately. 
To see which versions of Node.js are available for installation, type:

nvm ls-remote
Output

... 
         v6.8.0 
         v6.8.1 
         v6.9.0 (LTS: Boron) 
         v6.9.0 (LTS: Boron) 
         v6.9.0 (Latest LTS: Boron) 
         v7.0.0 
         v7.1.0 
         v7.2.0
As you can see, the latest version at the time of writing is v7.2.0, but v6.9.2 is the latest version supported in the long term. You can install it by typing:

nvm install 6.9.2
You will see the following outputs:

Computing checksum with sha256sum 
Checksums matched! 
Now using node v6.9.2 (npm v3.10.9) 
Creating default alias: default -> 6.9.2 (-> v6.9.2)
Typically, it will switch nvmto using the newly installed version. But you can tell nvmexplicitly using the version we just uploaded by typing:

nvm use 6.9.2
You can see the currently used version by typing in the command interface:

node -v
Output

v6.9.2
If you have multiple versions of Node.js, you can tell which one was installed by typing:

nvm ls
If you want to make one of these versions your default copy, you can type:

nvm alias default 6.9.2
This version will be automatically selected when you open a new session on the terminal terminal. You can also refer to it using the name defaultlike this:

nvm use default
Each version of Node.js will continue its own packages and will be npmavailable to manage them. 
You can place installation packages npmin the ./node_modulesNode.js project folder by using the normal format. For example, for a unit express:

npm install express
If you want to install it completely (make it available to other projects that use the same version of Node.js), you can add flag -g as follows:

npm install -g express
This will fix the package at:

~ / .nvm / node_version / lib / node_modules / package_name
The overall installation will allow you to run Help from the command line, but you will have to link the package from your local sphere to access it from within a program:

npm link express
You can learn more about the options available to you with nvmtyping:

nvm help
summary
As you have seen, there are several ways to install and run Node.js on a Debian server 8. Your circumstances will dictate you any of the above methods will be better for you. While the packaged version packaged in the Ubuntu repository is the easiest, the method is nvmdefinitely more flexible
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,