How to Install Node.js on Linux Mint 21 or 20

Node.js, a powerful JavaScript runtime built on Chrome’s V8 JavaScript engine, has revolutionized the way developers create server-side applications. This guide will demonstrate how to install Node.js on Linux Mint 21 or 20, enabling you to harness its full potential for building scalable and efficient web applications. Let’s delve into the distinct features of Node.js:

  • Event-Driven Architecture: Optimizes throughput and scalability in web applications with many input/output operations.
  • Non-Blocking I/O Model: Enhances performance and concurrency, making it ideal for data-intensive real-time applications.
  • Cross-Platform Compatibility: Runs on various operating systems, including Windows, macOS, and Linux.
  • Large Ecosystem: Access to an extensive range of npm modules and tools.
  • V8 Engine: Leverages Google Chrome’s V8 engine for fast execution of JavaScript.
  • Community Support: Benefits from a vibrant and active community, providing robust support and continuous enhancements.

With these features, Node.js stands out as an essential tool for modern web development. The upcoming sections will guide you through the installation process on Linux Mint, ensuring a smooth and efficient setup for your development environment.

Install Node.js on Linux Mint 21 or 20 via Default APT Repository

Step 1: Refresh APT Repository Before Node.js Installation

To ensure a smooth installation of Node.js on your Linux Mint system, begin by updating your system’s package list. This step is crucial for maintaining software compatibility and acquiring the most recent version of Node.js compatible with Linux Mint.

Run this command to update your system:

sudo apt update && sudo apt upgrade

Here, sudo apt update refreshes the package list, and sudo apt upgrade updates the software to their latest versions. This dual-action command streamlines the process, ensuring your system is ready for Node.js installation.

Step 2: Install Node.js via APT Command

With your system updated, you can now proceed to install Node.js. The Linux Mint default repository offers a pre-packaged version of Node.js, facilitating an uncomplicated installation.

Install Node.js by executing:

sudo apt install nodejs

This command triggers the installation of Node.js on Linux Mint. The process is automatic, requiring no additional input or configuration.

Step 3: Verifying Default APT Node.js Installation

Post-installation, it’s a good practice to confirm that Node.js has been installed successfully. Verifying the installation guarantees that Node.js is operational on your system.

Check your Node.js version with this command:

node --version

If the installation was successful, this command will display the currently installed version of Node.js on your Linux Mint system.

Install Node.js on Linux Mint 21 or 20 via NodeSource

Step 1: Install Initial Packages Required

First, in your terminal, run the following command to install the initially required packages to install Node.js from NodeSource:

sudo apt install curl apt-transport-http ca-certificates

Step 2: Import NodeSource APT Repository

Initiate the Node.js installation by importing the NodeSource repository’s GPG key. This step ensures the authenticity of the packages you’ll install. Use the following command:

curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/nodesource.gpg

Next, specify the Node.js version for your Linux Mint system. Replace NODE_MAJOR=20 with the required version, such as NODE_MAJOR=18. Execute this command:

echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg]$NODE_MAJOR.x nodistro main" | sudo tee /usr/share/keyrings/nodesource.gpg

Available Node.js versions include:


Step 3: Install Node.js via NodeSource APT

With the NodeSource repository added, install Node.js using the following command. This approach provides the latest or specific versions of Node.js, enhancing your system beyond the default repository offerings:

sudo apt install nodejs

This command installs Node.js along with all necessary dependencies, tailored to the version you selected during the repository setup.

After installation, verify the Node.js version to ensure everything is correctly set up:

node --version

The displayed version number confirms the successful installation of Node.js on your Linux Mint system.

Install Node.js on Linux Mint 21 or 20 via Node Version Manager (NVM)

Step 1: Install NVM on Linux Mint

To initiate the installation of Node.js on your Linux Mint system, start by installing Node Version Manager (NVM). NVM is a versatile tool that allows you to manage multiple Node.js versions, catering to different project requirements.

Run one of these commands to install NVM:

curl -o- | bash


wget -qO- | bash

Both commands download and execute the NVM installation script. After completing the installation, either restart your terminal or load NVM with:

source ~/.bashrc

Step 2: Install Node.js via NVM

With NVM installed, you gain the ability to manage various Node.js versions on your system.

Listing Available Node.js Versions

Check available Node.js versions by running:

nvm ls-remote

This command lists all Node.js versions available for installation, allowing you to select the most suitable one, such as the latest LTS release or a specific version.

Installing a Node.js Version

To install a particular version of Node.js, use:

nvm install <version>

Replace <version> with your desired Node.js version. For example, to install version 20.0.0, execute:

nvm install 20.0.0

This command downloads and installs the chosen Node.js version.

Verifying Node.js Installation

After installation, verify the installed Node.js version with:

node --version

This command outputs the installed Node.js version, confirming a successful installation.

Switching Between Installed Node.js Versions

NVM enables easy switching between Node.js versions. To switch, use:

nvm use <version>

For instance, to switch to Node.js version 18.16.0, run:

nvm alias default 18.16.0

This command activates the specified Node.js version for your session.

To set a default Node.js version for new terminal sessions, execute:

nvm alias default <version>

For example, to make version 18.16.0 the default, run the following:

nvm alias default 18.16.0

This command sets your chosen Node.js version as the default for future terminal sessions.

Managing Node.js on Linux Mint 21 or 20

Remove Node.js From Linux Mint

Remove Node.js Installed from Linux Mint Repository or NodeSource

To uninstall Node.js that was installed via the Linux Mint repository or NodeSource, use the apt package manager. This method applies to installations that were not done using NVM.

Execute the following command:

sudo apt remove nodejs

This command begins the process of removing Node.js and its associated configuration files. A confirmation prompt will appear before the uninstallation proceeds. Once confirmed, the removal of Node.js from your system will start.

Uninstall Node.js Installed via NVM

For Node.js installations done using Node Version Manager (NVM), a different approach is required.

Determining the Current Node.js Version

Identify the currently installed Node.js version with:

nvm current

This command outputs the version of Node.js presently in use, providing clarity on which version is to be uninstalled.

Deactivating NVM

Prior to uninstalling Node.js, deactivate the current version managed by NVM. To deactivate, run:

nvm deactivate

This command unloads the active Node.js version, setting the stage for its removal.

Uninstalling a Specific Node.js Version Using NVM

With NVM deactivated, you’re set to uninstall a specific Node.js version. Substitute <version> in the command below with the version you wish to remove:

nvm uninstall <version>

For example, to uninstall Node.js version 20.0.0:

nvm uninstall 20.0.0

Executing this command eliminates the chosen Node.js version from your system, completing the uninstallation.

Wrapping Up Installing Node.js on Linux Mint

Throughout this guide, we’ve comprehensively covered the installation of Node.js on Linux Mint 21 and 20, navigating through three effective methods. Starting with the simple installation from the Linux Mint repository, we then explored the versatile NodeSource repository option, offering greater control over version selection. The journey continued with Node Version Manager (NVM), an invaluable tool for juggling multiple Node.js versions.

We also delved into the clean uninstallation of Node.js, whether it’s from the repository, NodeSource, or via NVM, ensuring your system remains organized and efficient. As you move forward with Node.js, remember these steps and tips to optimize your development environment and keep it running smoothly.

Leave a Comment