JavaScript Ubuntu

Install npm Linux Mint 20

Whenever we are working in any run-time environment, we always need a good package manager that can handle the installation of all the related packages very gracefully. npm refers to the default package manager of Node.js which is the run-time environment for JavaScript. Before installing npm, we must have Node.js environment ready for us. Therefore, in this article, we will walk you through the method of installing npm in Linux Mint 20.

Methods of installing npm Linux Mint 20:

For installing npm on Linux Mint 20, you can make use of any of the two methods discussed below:

Method # 1:

For installing npm on Linux Mint 20 from NodeSource, you will need to perform the following steps:

  • Launch the terminal in Linux Mint 20 by clicking on the terminal icon located on your taskbar. The newly launched terminal window is shown in the image below:

  • Now you need to enable the NodeSource repository. For doing that, type the following command in your terminal and then press the Enter key:
curl –sL https://deb.nodesource.com/setup_12.x | sudo -E bash

This command is also shown in the following image:

  • Once the NodeSource repository has been successfully enabled, your terminal screen will look something like this:

  • Now you need to install the nodejs package which contains binaries for both npm and node. For doing that, type the following command in your terminal and then press the Enter key:
sudo apt install nodejs

This command is shown in the image below:

  • Once all the binaries within this package have been installed successfully, you will be able to see the output shown in the following image:

  • Now you need to verify if Node.js has been successfully installed on your system or not. For doing that, type the following command in your terminal and then press the Enter key:
node --version

This command is also shown in the image below:

  • The Node.js version is shown in the following image:

  • For verifying the npm version, type the following command in your terminal and then press the Enter key:
npm --version

This command is shown in the image below:

  • The npm version is shown in the following image:

Method # 2:

For installing npm on Linux Mint 20 by making use of Linux Repository, you will need to perform the following steps:

  • Launch the terminal in Linux Mint 20 in the same way as it is described in the method above. Now type the following command in your terminal for updating your Linux repository and then press the Enter key:
sudo apt update

This command will take some time to execute as it requires updating all the necessary packages before installing a new one. It is shown in the image below:

  • As soon as all the necessary packages have been updated in your Linux repository, you will be able to see the following output on your Linux Mint 20 terminal:

  • Now type the following command in your terminal for installing the nodejs package which contains binaries for npm as well as for Node.js and then presses the Enter key:
sudo apt install nodejs

This command is shown in the image below:

  • Once the nodejs package has been successfully installed, you will be able to see the following output on your terminal:

  • For verifying if Node.js and npm have been successfully installed or not, you can simply run the respective version commands as described in the method above. Now if you want to enable ad-ons from npm, you will need to install the development tools. For doing that, type the following command in your terminal and then press the Enter key:

sudo apt install build-essential

This command is also shown in the image below:

  • As soon as the development tools will be installed successfully, you will be able to see the following output on your Linux Mint 20 terminal:

Conclusion:

By making use of any of the two methods discussed in this article, you can easily install npm on Linux Mint 20. Both these methods are extremely simple and convenient to follow and work fine in all situations. Therefore, it is only a matter of your own choice which method you decide to follow.

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn.