In this tutorial we shall perform an installation of Node.js 10 on Debian 11/10/9. Node.js is a cross-platform and open-source JavaScript runtime environment built on Chrome’s V8 JavaScript engine. Node.js executes JavaScript code outside a web browser hence efficient in performance and resource management.

Node.js is single-threaded in nature nature, making it fit for use in non-blocking, event-driven development. Node.js was designed to power real-time and push-based application architectures.

There are two common methods from which you can install Node.js on Debian 11/10/9 Linux system.

The first method is fit for actively supported LTS releases of Node.js. As of this article update, these are:

  • Node.js 12 LTS “Erbium”
  • Node.js 14 LTS “Fermium”
  • Node.js 16 “Gallium”

Node.js 10 is not under active / extended LTS support. For this reason, we cannot perform its installation from the Nodesource repository.

Install Node.js 10 on Debian 11/10/9 using NVM

NVM is a version manager for node.js and it allows you to quickly install and use different versions of node via the command line. NVM has to be installed before you can install Node.js 10 on Debian 11/10/9 using NVM.

To install Node Version Manager on your Debian system, use the following commands:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash

This configures NVM environment on your bashrc or zshrc file depending on the active SHELL

#Bash SHELL
source ~/.bashrc

#Zsh SHELL
source ~/.zshrc

Test the NVM environment is working:

$ echo $NVM_DIR
/home/debian/.nvm

You can list available releases of Node.js that can be installed using NVM.

$ nvm list-remote
....filtered_output...
v10.0.0
v10.1.0
v10.2.0
v10.2.1
v10.3.0
v10.4.0
v10.4.1
v10.5.0
v10.6.0
v10.7.0
v10.8.0
v10.9.0
v10.10.0
v10.11.0
v10.12.0
v10.13.0 (LTS: Dubnium)
v10.14.0 (LTS: Dubnium)
v10.14.1 (LTS: Dubnium)
v10.14.2 (LTS: Dubnium)
v10.15.0 (LTS: Dubnium)
v10.15.1 (LTS: Dubnium)
v10.15.2 (LTS: Dubnium)
v10.15.3 (LTS: Dubnium)
v10.16.0 (LTS: Dubnium)
v10.16.1 (LTS: Dubnium)
v10.16.2 (LTS: Dubnium)
v10.16.3 (LTS: Dubnium)
v10.17.0 (LTS: Dubnium)
v10.18.0 (LTS: Dubnium)
v10.18.1 (LTS: Dubnium)
v10.19.0 (LTS: Dubnium)
v10.20.0 (LTS: Dubnium)
v10.20.1 (LTS: Dubnium)
v10.21.0 (LTS: Dubnium)
v10.22.0 (LTS: Dubnium)
v10.22.1 (LTS: Dubnium)
v10.23.0 (LTS: Dubnium)
v10.23.1 (LTS: Dubnium)
v10.23.2 (LTS: Dubnium)
v10.23.3 (LTS: Dubnium)
v10.24.0 (LTS: Dubnium)
v10.24.1 (Latest LTS: Dubnium)
....

We can now install Node.js 10 on Debian 11|10|9 Linux machine using NVM package manager:

$ nvm install v10
Downloading and installing node v10.24.1...
Downloading https://nodejs.org/dist/v10.24.1/node-v10.24.1-linux-x64.tar.xz...
############################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
manpath: can't set the locale; make sure $LC_* and $LANG are correct
Now using node v10.24.1 (npm v6.14.12)

The command executed installs the latest version of Node.js 10. If you need a specific version install like below:

$ nvm install <version>
###Examples###
nvm install v10.24.1
nvm install v10.24.0

Check Node.js versions installed by NVM;

$ nvm ls
-> v10.24.1
v12.22.7
default -> v12 (-> v12.22.7)

To set the default version of Node.js as 10, run the command:

$ nvm use 10
Now using node v10.24.1 (npm v6.14.12)

$ nvm alias default 10
default -> 10 (-> v10.24.1)

$ nvm ls
-> v10.24.1
v12.22.7
default -> 10 (-> v10.24.1)

Checking the current version set using node command:

$ node -v
v10.24.1

Installing Node.js Development tools

For guys interested in building native Node.js addons, you may need to install standard dev tools:

sudo apt update
sudo apt install gcc g++ make

Yarn package manager can also be installed using the commands provided below:

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn

How To Use Node.js 10 on Debian 11|10|9

With Node.js 10 installed on our Debian 11/10/9 system, let’s create Hello World test application.

Create new file named helloworld.js;

vim helloworld.js

Paste the contents below. You can modify it to your liking.

const http = require('http');

const hostname = '0.0.0.0';
const port = 3000;

const server = http.createServer((req, res) =>
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World from Node Server');
);

server.listen(port, hostname, () =>
console.log(`Server running at http://$hostname:$port/`);
);

To start Node.js web server, run:

$ node helloworld.js
Server running at http://0.0.0.0:3000/

Then access test Node.js application on http://ServerIP_or_Hostname:3000. You should see a page like one in the screenshot.

nodejs-hello-world-app.png

To stop Node.js web server, press CTRL+C in your keyboard. You should be having a working installation of Node.js 10 on Debian 11/10/9 by the end of this post. For any errors or issues use comments section to reach out.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ComputingPost

ComputingPost

ComputingPost — Linux Howtos, Tutorials, Guides, News, Tips and Tricks.