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.
So, now that you have the repository set up, you can install NodeJS normally through `apt`.
# apt install nodejs
Test NodeJSMake 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
$ npm install express
Like any package manager, NPM will pull in Express along with all of its dependencies.
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.
ARE YOU LOOKING FOR A LINUX JOB? Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
DO YOU NEED ADDITIONAL HELP? Get extra help by visiting our LINUX FORUM or simply use comments below.