We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

24
938.215,85

Cart

Quantity 185.000,00
Quantity 2.750,00
Quantity 18,00

Learn how to – How To Install Node.js 12 on Debian 11/10/9

Learn how to – How To Install Node.js 12 on Debian 11/10/9.

Welcome to today’s guide on how to install Node.js 12 LTS on Debian 11/10/9. Node.js is a free to use, open-source, and cross-platform JavaScript runtime environment used to develop server-side applications. Node.js is known for its powerful event-driven and non-blocking I/O model hence perfect for data-intensive real-time applications that run on distributed platforms.

There are two main ways of installing Node.js 12 on Debian 11|10|9 Linux system.

  1. Installation from Nodesource APT repository
  2. Installation by 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.

As of this article update below are actively supported LTS releases of Node.js

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

Install Node.js 12 on Debian 11/10/9 from Nodesource repo

The Nodesource software company builds and host supported versions of Node.js. We will add the repository to our system and then install Node.js 12 on Debian 11/10/9.

Add the repository and install Node.js 12 on Debian 11/10/9 by running the following commands in your terminal.

sudo apt update
curl -fsSL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install -y nodejs

Confirm Node version after the installation:

$ node -v
v12.22.7

Install Development tools an Yarn

If you’ll be building native Node.js addons, install the development tools:

sudo apt update
sudo apt install gcc g++ make

Run the following commands to install the Yarn package manager:

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

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

Run below commands to download and install Node Version Manager

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

Source your bashrc file to start using nvm

source ~/.bashrc

To list available versions of Node.js that can be installed using nvm:

nvm list-remote

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

$ nvm install v12
Downloading and installing node v12.22.7...
Downloading https://nodejs.org/dist/v12.22.7/node-v12.22.7-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 v12.22.7 (npm v6.14.15)
Creating default alias: default -> v12 (-> v12.22.7)

The installation can be confirmed using node and nvm commands:

$ node -v
v12.22.7

$ nvm ls
->     v12.22.7
default -> v12 (-> v12.22.7)
iojs -> N/A (default)

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

$ nvm use 12
manpath: can't set the locale; make sure $LC_* and $LANG are correct
Now using node v12.22.7 (npm v6.14.15)

Using Node.js 12 on Debian 11/10/9

After a successfully installation of Node.js 12 on our Debian system, we can create a hello world Node application to demonstrate its usage.

Create helloworld.js file

vim helloworld.js 

Add below contents

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}/`);
});

Start Node.js web server to test our application:

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

Access your Node.js application at http://IP_Address:3000 on your web browser.

As seen on the screenshot, we have been able to install Node.js 12 successfully on our Debian 11/10/9 Linux system. You can stop the web server using CTRL+C key combination. We hope this guide was of benefit to you. Cheers!

Node.JS Programming Udemy Video Courses

24
938.215,85

Cart

Quantity 185.000,00
Quantity 2.750,00
Quantity 18,00