How to Install NPM on Linux Mint

How to Install NPM on Linux Mint

Figuring out how to install NPM on Linux Mint is essential for managing JavaScript packages. And we’re here to help you walk through it all in this article. 

Web Development: The Basics

Web development is the most saturated programming category, and this is for good reasons. Developing web apps with JavaScript is relatively simple. It comes with tons of frameworks and tools that are available for free, saving you a lot of time. And since JavaScript can run inside a web browser, it can also be used to run apps across all types of devices. 

This means you also already have all the tools you need to build out your ideas. Plus, you don’t have to worry about writing the same app in many different languages to accommodate multiple devices.

As of 2022, 98% of websites have client-side Javascript code for webpage behavior. Every web browser has a dedicated JavaScript engine to execute the code on the user’s device. But when developing apps, we might want to be able to run that code outside of a web browser.

That’s where Node.js comes in, an open-source JavaScript runtime environment built on Google Chrome’s JavaScript engine. With Node.js, we can also execute JavaScript code outside of a web browser, and it was designed to build scalable network applications.

How to Install NPM on Linux Mint

There are many Node.js packages, and manually downloading, installing, and solving conflicts between these packages can be a huge hassle. Luckily there is npm (Node Package Manager). As the name implies, it is a package manager for the JavaScript programming language—specifically for the JS runtime environment Node.js.

Npm also stands for “npm is not a package manager,” It is entirely written in JavaScript and developed by Isaac Z. Schlueter.

Update Your Current Package List

We will start by updating our current package list with the apt update.


$ sudo apt update

Install node.js Using apt

The nodejs package is provided in Mint’s official repositories, so install it using apt.


$ sudo apt install nodejs -y

We can confirm that nodejs was successfully installed by checking the version. This can be done by typing in the following command:

$ nodejs --version v12.22.9

Install npm Using apt

The npm package is provided in Mint’s official repositories, so simply install it using apt.


$ sudo apt install npm -y

The installation may take minutes, depending on your internet connection.

Once again, we can check the version to ensure npm was successfully installed.


$ npm --version 8.5.1

How to Use npm

Using npm is very easy, and the syntax is similar to the apt package manager. Do this by typing the following command:

$ npm --help

Looking at the help page, we can see that packages are installed by typing npm install in the terminal.

npm install

For more details, we can also look at the manual page for npm by typing man npm into the terminal.

Installing Packages Locally and Globally

There are two ways packages can be installed using npm. The way that we have already shown is how you install packages locally. Packages should be installed locally if you intend to use them for a specific project only & don’t want to have them in your other projects.

Here is an example of installing the chalk package locally:

$ npm install chalk

To install packages locally, navigate to the project directory and install the packages using npm install. If you would like a package installed globally to have it accessible from any project, you simply need to add the -g or –global flag.

It’s important to note that when installing packages globally, you will have to prefix the command with the sudo command since the global packages are installed in the /usr/local/lib/node_modules directory by default.

Installing the chalk package globally would look something like this:

$ sudo npm install -g chalk

Removing npm Packages

To remove an npm package, simply run the npm uninstall command. Once again, if you want to remove a local package, navigate to the project directory where the package is installed and run the command.

$ npm uninstall chalk

And if you would like to remove a global package, add the -g or –global flag and run the command with sudo privileges.


$ sudo npm -g uninstall chalk

List Installed packages

To list all installed packages, use the npm ll command. Same as before, if you want to list the locally installed packages, navigate to the project directory and run this command:

$ npm ll

And if you want to list all the globally installed packages, add the -g flag again. However, this time we won’t need sudo since we are only reading from the directory and not writing to it.


$ npm -g ll

Remove node.js and npm

If you want to remove node.js and npm from your computer, you can run the following command:

$ sudo apt purge --autoremove npm nodejs

Remember that this will not delete your packages installed with npm, so if you want to remove everything, make sure to uninstall the packages you installed with npm and then remove them.

If you’re looking to build web apps, npm is a powerful tool you should consider. With over 1.3 million packages in its repositories, npm can save you time and make it easier to focus on building out your ideas straight away instead of having to worry about building the tools first. 

If this guide helped you, please share it.

Leave a Reply
Related Posts