How To Install Node.js on Linux Mint

Need to install a Node.js in Linux Mint? If so, I’ll show you two ways of installing Node.js on Linux Mint. The two ways are:

  • installing Node.js from repositories
  • using Node Version Manager - nvm

Solution 1: Install Node.js from repositories in Linux Mint

Step 1.1: Update packages and install Node.js

It's a good practice before any installation from the repositories to update the packages. This can be done by:

sudo apt update

Then you can install latest available Node.js by next command:

sudo apt install nodejs

You will need to enter your root password.
Once the installation is complete you can check the version and verify the installation by:

nodejs -v

result:

v8.10.0

Step 1.2: Install npm on Linux Mint

Many programs like JupyterLab will require npm to be installed in order to work. npm which stands for Node Package Manager can be installed on Linux Mint by:

sudo apt install npm

Step 1.3: Upgrade Node.js which is installed from repositories

Often the installed Node.js version from the repositories will be outdated. If you need to upgrade Node.js to the latest version you can use module n.

The module n will take care for the upgrade of Node.js when it's installed from PPA.

Install module n by:

npm install n -g

Then you can install the stable Node.js by:

n stable

or the latest:

n latest

Note 1: Depending on the OS, versions etc you may need to use sudo.

Note 2: There was a naming problem in the past for package node in Ubuntu. Which causes coexistence of node and nodejs commands in Linux Mint. Some programs will require nodejs others node. This should be handled with alias. You can check the output of the next command in order to find what versions do you have:

node -v
nodejs -v

and

which node
which nodejs

Solution 2: Install Node.js with nvm on Linux Mint

The second way which is better and my preferred one is installing nvm and using it to install node.

Step 2.1 Install nvm on Linux Mint

The nvm installation guide is available on : nvm Install & Update Script. So in order to install nvm on Linux Mint you can follow. Get the latest installation script from the page above:

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

Note 1: this will download and run the script. If you like you can download it, review it and then install it.

Note 2: You need to start a new terminal or run command: source ~/.bashrc in order to use nvm command.

Step 2.2 List Node versions with nvm

There are many different node packages available. In order to list all of them with nvm you can use command:

nvm list-remote

result

       v14.14.0
       v14.15.0   (LTS: Fermium)
->     v14.15.1   (Latest LTS: Fermium)
        v15.0.0
        v15.0.1
        v15.1.0
        v15.2.0
        v15.2.1
        v15.3.0
        v15.4.0

Step 2.3 Install Node.js with nvm

When you find what version you like to use then you can install it by:

nvm install v15.0.0

Step 2.4 Use multiple Node.js versions with nvm

It's common to have several Node.js versions. The best way to manage them is with nvm. Local Node.js versions can be listed by:

nvm list

output:

       v12.18.3
->     v14.15.1
         system
default -> node (-> v14.15.1)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.15.1) (default)
stable -> 14.15 (-> v14.15.1) (default)
lts/* -> lts/fermium (-> v14.15.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.23.0 (-> N/A)
lts/erbium -> v12.20.0 (-> N/A)
lts/fermium -> v14.15.1

If you need to change the default one you can do it by:

nvm use v12.18.3

Finally, check the Node version by:

node -v or nodejs -v

Share Tweet Send
0 Comments
Loading...