Install the latest stable release of NodeJS on Debian Stretch.


Debian 9 Stretch


This guide requires a functional install of Debian Stretch with root privileges.




  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - requires given linux commands to be executed as a regular non-privileged user


NodeJS is on the rise, big time. It's one of the top web development tools, and when paired with the Express framework, it's solid direct competition to the likes of PHP and Ruby on Rails. Debian provides NodeJS in its repositories, but it's usually extremely out-of-date. There's no need to worry. The NodeJS Foundation recommends a Debian repository hosted by a popular NodeJS hosting service.

Get And Run The Script

This part is super easy. It's actually what's recommended by the NodeJS Foundation. Use cURL to pull this Bash script. The script detects your distribution and sets up the repository for you. It even runs `apt update`. You should probably have `sudo` installed. If not, you either need to run the script as root(not usually a good idea). Just run the script separately instead of using the pipe.

With Sudo

$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.

Without Sudo

$ cd Downloads
$ curl -sL https://deb.nodesource.com/setup_10.x > setup_10.x 
$ chmod +x setup_10.x
# ./setup_10.x

Install NodeJS

So, now that you have the repository set up, you can install NodeJS normally through `apt`.
# apt install nodejs

Test NodeJS

Make sure that Node is installed and working properly. You can check that it's there with the `-v` flag.
$ node -v

Install With NPM

Before you get started with NPM, install some development packages so NPM won't have a problem when it encounters a source package.
# apt install build-essential libssl-dev
Now, you can install anything that's available in the NPM repositories. NPM is a NodeJS package manager, but it also handles loads of other JavaScript packages. Think of it like the JavaScript version of `pip` or Ruby gems. Try installing the Express. It's easily the most widely used NodeJS framwork, and it's a good place to start with Node.
$ npm install express
Like any package manager, NPM will pull in Express along with all of its dependencies.

Closing Thoughts

NodeJS is only going to continue to grow. Debian Stretch can be an excellent platform to develop on. With the use of this repository, you can make sure that you always have the latest stable release. NPM is huge. It's way too big to cover here, but it's worth taking a look at. There are loads of great packages and resources available there for both front and back end development.
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:

Comments and Discussions