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
- $ – 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.
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
$ cd Downloads $ curl -sL https://deb.nodesource.com/setup_10.x > setup_10.x $ chmod +x setup_10.x # ./setup_10.x
So, now that you have the repository set up, you can install NodeJS normally through `apt`.
# apt install 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
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.
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.