• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Node.js on Debian 10/9/8

Written by Rahul, Updated on September 21, 2020

Node.js is a platform built on Chrome’s V8 JavaScript engine.Nodejs can used for easily building fast, scalable network applications. Latest version node.js ppa is maintaining by its official website. We can add this PPA to Debian 10 (Buster), Debian 9 (Stretch) Debian 8 (Jessie) and Debian 7 (Wheezy) systems. Use this tutorial to install latest Nodejs & NPM on Debian 10/9/8/7 systems.

To install specific nodejs version, Visit our tutorial Install Specific Nodejs Version with NVM.

Install nodejs on Debian

Step 1 – Add Node.js PPA

You are required to add Node.js PPA to your system provided by the Nodejs official website. We also need to install the software-properties-common package if not installed already. You can choose either to install the latest Node.js version or LTS version.

For Latest Release

sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -

For LTS Release

sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -

Step 2 – Install Node.js on Debian

After adding the required PPA file lets install Nodejs package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

sudo apt-get install nodejs
  • Don’t Miss => Yarn Installation ( A Node Modules Manager)

Step 3 – Check Node.js Version

After completeing the installation, check and verify the installed version of Node.js and NPM. You can find more details about current version on node.js official website.

node -v 

v14.11.0

Also, check the version of NPM.

npm -v 

6.14.8

Step 4 – Create Demo Web Server (Optional)

This is an optional step. If you want to test your node.js install. Let’s create a web server with “Hello World!” text. Create a file http_server.js

vim http_server.js

and add the following content

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3000/');

Now start the node service using the following command.

node http_server.js

Server running at http://127.0.0.1:3000/

Web server has been started on port 3000. Now access http://127.0.0.1:3000/ url in browser.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

21 Comments

  1. Avatar Fresko Reply
    March 16, 2020 at 6:02 pm

    Спасибо, друг!!!

  2. Avatar Daniel Ellis Reply
    March 2, 2020 at 1:09 pm

    Great write-up.
    I really appreciate the way you have written and explained. Worth reading it.
    Thanks for sharing it with us.
    Good work..!

  3. Avatar Steve Alex Reply
    February 15, 2020 at 7:13 pm

    Nice clean explanation, about the same I’ve seen the last few days, but it still does not work for me!

    Debian 10, actually Raspberrium running on old iMac. No mater what I try, after I add the LTS release (setup_12.x) , the apt-get update will show the correct targets.

    But when I do apt-get install nodejs, it will default back to the debian package (v10.15.2) which creates segmentation faults on a yarn install command.

    I don’t know if its the raspberrium packages but it will alway go to the default, even if I purge nodejs.

    I’ve pushed this truck up to hill so many time with the same results – I’m just lost
    (https://www.cs.uni.edu/~mccormic/humor.html)

    • Avatar Steve Alex Reply
      February 15, 2020 at 7:39 pm

      I’ll comment to myself!

      Well if I would have read a little further I would of let the ‘raspian’ comment sink in. I assumed it was running 64 bit(dual core), but all the packages are 32bi – guess raspian in build from 32 bit debian.

      Guess it was a bad choice for staging server, guess I’ll have to install pure Debian on it

  4. Avatar Sergio Reply
    January 17, 2020 at 5:28 pm

    Thank you a lot! Really works!

  5. Avatar Nitin Reply
    November 13, 2019 at 1:27 pm

    Many thanks, precise instructions with additional/optional info!
    Kudos!!

  6. Avatar Alex Reply
    June 14, 2019 at 7:22 am

    Thank’s. Short and clear!

  7. Avatar Anmol Reply
    June 12, 2019 at 11:45 am

    thanks . helped a lot.

  8. Avatar Emerson Reply
    May 23, 2019 at 3:22 pm

    on raspbian

    ## Installing the NodeSource Node.js 12.x repo…

    ## You appear to be running on ARMv6 hardware. Unfortunately this is not currently supported by the NodeSource Linux distributions. Please use the ‘linux-armv6l’ binary tarballs available directly from nodejs.org for Node.js 4 and later.

    the 12 version don’t have an armv6, wath can I do?

  9. Avatar Michael Reply
    April 13, 2019 at 6:11 pm

    Thank you!

  10. Avatar Frank Reply
    March 27, 2019 at 12:14 pm

    Thanks, it is working.
    @AuronStrc I’m using Debian as well – but buster/sid.
    However, do install proposed official Nodejs repo, than you will have latest or LTS version.
    Best,
    Frank

  11. Avatar nacim Reply
    February 9, 2019 at 8:34 pm

    thank you !

  12. Avatar AuronStrc Reply
    January 28, 2019 at 1:55 pm

    Debian v9.7:

    [email protected]:/tmp# node -v
    -bash: node: command not found

    [email protected]:/tmp# npm -v
    -bash: npm: command not found

    [email protected]:/tmp# nodejs -v
    v4.8.2

    ..what’s wrong?

    • Avatar Italo Cruz de Brito Reply
      March 27, 2019 at 12:36 pm

      Just do apt-get update before installing nodejs

  13. Avatar Tomas Reply
    August 31, 2018 at 5:52 am

    Thanks for your article, great info!

  14. Avatar Ryan Reply
    July 10, 2018 at 10:42 pm

    Hey is there any way to update? My system downloaded v3.5.2

  15. Avatar Reginaldo Barreto Reply
    March 18, 2018 at 2:23 am

    Thanks for sharing this information.

  16. Avatar Josef Reply
    January 18, 2018 at 3:44 am

    V. Nice Tutorial. Thanks

  17. Avatar Eugene Reply
    January 17, 2018 at 11:18 pm

    Worked like a charm, thanks! Is there an easy way to update?

  18. Avatar Dan Reply
    October 24, 2017 at 5:43 am

    On Raspbian (Debian Stretch) :
    sudo apt-get install curl python-software-properties

    doesn’t work, should be :
    sudo apt-get install curl software-properties-common

    • Avatar Vishnu Reply
      January 22, 2018 at 6:34 am

      software-properties-common
      is an alternate for
      python-software-properties

      some systems have it.. some don’t

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy