How to Resolve (Command ‘npm’ not found) Error?

NPM (Node Package Manager) manages the packages of the JavaScript and also the dependencies with those packages. It offers tens of codes that are frequently used by the developers across all the platforms, i.e., Windows/Linux/macOS.

 Command npm not found
Command npm not found Fix

In Linux, the command not found errors are frequently observed and the main cause of these errors is that the system is missing the required command/keyword. The same goes with the phrase “Command ‘npm’ not found”. Therefore, the error occurs whenever users try to utilize the “npm” keyword in the absence of the Node Package Manager.

In today’s guide, we will address the possible causes and solutions of the error, “Command ‘npm’ not found”.

Why This Error Occurs?

As discussed earlier, the NPM command not found error occurs when the users try to run the NPM command from the terminal. The error snippet is shown in the figure below:

npm not found error
NPM command not found error

Solution: Install NPM

The primary solution to fix this error is to install the NPM on your Linux system. Let’s understand the solution with the steps:

Step 1: Install NPM on Linux

To install NPM on your Linux systems, use one of the following commands as per the Linux distribution you are using:

$ sudo apt install npm                                   #For Debian/Ubuntu-based Systems
$ sudo yum install npm                                   #For RHEL/CentOS-based
$ sudo dnf install npm                                   #For Fedora-based
$ sudo pacman -S npm                                     #For Arch-based
$ sudo zypper install npm                                #For OpenSUSE-based
install npm
Installing NPM 1/2
install npm
Installing NPM 2/2

Step 2: Verify the Solution

Once it is installed, verify that it is fixed using the command:

$ npm
verifying NPM
Verifying NPM

The output shows that the error has been fixed.

How to Use NPM on Linux?

Once the NPM command is working on your system, the users can utilize it to search, install, remove, and many other operations using the terminal. Some of the most used NPM commands are mentioned below:

To search for any package:

$ npm search package

To install any package:

$ npm install package

To remove any package:

$ npm uninstall package

To get the list of installed packages:

$ npm ls

The error “Command ‘npm’ not found” occurs when the “npm” is not installed on the system. In the absence of NPM, the user won’t be able to execute the NPM. To fix the error, the NPM must be installed on the Linux system as per your distribution, i.e., Debian-based, RHEL-based, CentOS-based. We have illustrated the reasons and the possible fix to the error.

ABOUT THE AUTHOR

Muhammad Zubyan


Muhammad Zubyan is a certified Google IT Support Professional with over 7 years of extensive experience. He has worked on more than 1500 computers, gaining valuable insights that enable him to detect and troubleshoot any complicated root cause of Windows-related issues and errors. In addition to managing Appuals as a Senior Editor, he is currently developing his own Game Optimization program that caters to both gamers and casual users alike.