Installing latest nodejs in Debain 8/7 or Ubuntu 16.04/14.04
Latest Nodejs versions are not yet included in the official Repositories, So we need to download the desired nodejs setup script. That will add the nodejs to our local repository, Then We can install the Latest NodeJS. Let’s get started.
Steps to Install the Nodejs 6_X:
Please run the following commands to install the nodejs 6_x version.
1 |
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - |
Then run the following command to install the nodejs
1 |
sudo apt-get install -y nodejs |
Now you can check the installed NodeJS and npm or node package manager versions using following commands
1 |
node -v |
1 |
npm -v |
Steps to install the Node.js v7:
Please run the following commands one by one to install the nodejs 6_x version.
1 |
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - |
Sample Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
root@ubuntu:~# curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - ## Installing the NodeSource Node.js v7.x repo... ## Populating apt-get cache... + apt-get update ......... Fetched 6,237 kB in 7s (890 kB/s) Reading package lists... Done ## Confirming "trusty" is supported... + curl -sLf -o /dev/null 'https://deb.nodesource.com/node_7.x/dists/trusty/Release' ## Adding the NodeSource signing key to your keyring... + curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - OK ## Creating apt sources list file for the NodeSource Node.js v7.x repo... + echo 'deb https://deb.nodesource.com/node_7.x trusty main' > /etc/apt/sources.list.d/nodesource.list + echo 'deb-src https://deb.nodesource.com/node_7.x trusty main' >> /etc/apt/sources.list.d/nodesource.list ## Running `apt-get update` for you... + apt-get update ............. Reading package lists... Done ## Run `apt-get install nodejs` (as root) to install Node.js v7.x and npm root@ubuntu:~# |
Now run the following command to install the NodeJS version 7_X
1 |
sudo apt-get install -y nodejs |
Sample Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
root@ubuntu:~# sudo apt-get install -y nodejs Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: nodejs 0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded. Need to get 11.1 MB of archives. After this operation, 55.6 MB of additional disk space will be used. Fetched 11.1 MB in 1s (6,634 kB/s) Selecting previously unselected package nodejs. (Reading database ... 64442 files and directories currently installed.) Preparing to unpack .../nodejs_7.7.4-1nodesource1~trusty1_amd64.deb ... Unpacking nodejs (7.7.4-1nodesource1~trusty1) ... Processing triggers for man-db (2.6.7.1-1ubuntu1) ... Setting up nodejs (7.7.4-1nodesource1~trusty1) ... root@ubuntu:~# |
Now, Check the installed nodejs version and NPM versions.
1 2 3 4 5 |
root@ubuntu:~# node -v v7.7.4 root@ubuntu:~# npm -v 4.1.2 root@ubuntu:~# |
That’s it. You successfully installed the Latest Nodejs in your Linux Machine.