How To Install Node.js on Linux Mint 22

Node.js is an open source Javascript runtime environment used in the development of web applications and network tools. It is built on the version 8 of Google Javascript Engine. It works on many platforms including Windows OS, Linux and Mac OS. This guide will cover installation of Node.js in Linux Mint 22.

With Node.js, you can use javascript as a server-side scripting language to create dynamic content for web pages.

How To Install Node.js in Linux Mint 22

Node.Js can be installed using three different methods:

  • Install Node.Js using NodeSource – NodeSource repository is set up in the Linux system to be used in installing Node.js
  • Install Node.Js using NVM (Node Version Manager) – NVM is a Node.Js version manager which is used in installing and managing Node.js and enables switching between varying node versions.
  • Install Node.Js using Ubuntu Repository – Node.js is installed from Ubuntu repository using the apt command

How To Install Node.js in Linux Mint 22 Using NodeSource

Here, we are going to install Node.js using NodeSource

Before installing Node.js in Linux Mint 22, ensure that your Linux repository index is updated using the below command:

sudo apt update

Install Curl and Build-essential

Curl is used for downloading official Node.js installation script while build-essential is for compiling and installing native addons:

sudo apt install curl build-essential

Add Nodesource Repository.

Run the command below to set up Nodesource repository in your system selecting what matches the Node.js version you want to install.

### Node.js 22###
curl -sL https://deb.nodesource.com/setup_22.x | sudo -E bash -
### Node.js 20###
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
### Node.js 18 ###
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
### Node.js 16 ###
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
### Node.js 14 ###
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
### Node.js 12 ###
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

Install Node.js on Linux Mint

After adding NodeSource repository, it is time to install Node.js. The command will also install NPM (Node Package Manager) which is a Javascript package manager.

sudo apt-get install nodejs -y

Sample Output:

Check Node.Js Version

Check Node.js version to verify installation

$ node -v
v22.14.0

Install Yarn Package Manager

Yarn Package Manager is an alternative of NPM (Node Package Manager) which presents higher operation speeds with improved security and reliability.

sudo npm install --global yarn

Run Your Web Server with Node.js

It is now time to run our first web server with Node.js. Create a file called test.js:

sudo vim test.js

Paste the below content in test.js. After pasting, press ctrl+ x, followed by y then Enter to save.

const http = require('http');
const port = 8080;
const server = http.createServer((req, res) => {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello World!\n');
});
server.listen(port, () => {
  console.log(`Node.js server listening on port ${port}`);
});

Start the Webserver with Node.js

The command below is used to start the Node.js web server running on port 8080:

node --inspect test.js

A successful installation outputs the below content showing the web server running on the specified port, 8080:

Verifying Node.js Installation

On your browser, type:

http://localhost:8080

If the installation is successful, you will get your web page with the words ‘Hello World!’:

This has been a step-by-step guide on how to install Node.js in Linux Mint 21 using NodeSource. Check more elaborate guides for your day-to-day Linux mint installations on our site.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Unlock the Right Solutions with Confidence

At CloudSpinx, we don’t just offer services - we deliver clarity, direction, and results. Whether you're navigating cloud adoption, scaling infrastructure, or solving DevOps challenges, our seasoned experts help you make smart, strategic decisions with total confidence. Let us turn complexity into opportunity and bring your vision to life.

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

WireGuard is a modern VPN that uses peer-to-peer kind of connectivity to establish the connection. It is a simple and […]

Eclipse Adoptium’s main objective is to produce high-quality runtimes and the associated technology to be used within the Java Ecosystem. […]

On latest releases of Rocky, AlmaLinux, CentOS operating systems, the old ifup and ifdown commands are not installed by default. […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.