NPM Command not Found

Npm stands for (node package manager) npm is a package manager in NodeJS and the NodeJS is a framework of javascript. The npm is a tool that is used to add, update, uninstall and install new packages for better performance and for performing specific tasks.

The NodeJS package manager first checks the requirements for which tool or site is required for performing a particular operation and then automatically installs that required package or tool which is in need. 

An npm contains the widest JS repository that allows you to search and install your desired packages, it lets you manage the installed packages as well.

Now if we talk about the npm command so it is used to install JS packages in our local systems but sometimes this command does not work well and you receive an error like this:

“npm command not found”

Several reasons for occurring “npm command not found”

  • The first and most common reason is “the node package manager(npm) is not installed”. This is the reason why the npm command not found error occurs because in the windows OS it happens sometimes that users forget to install the npm package While downloading NodeJS and unfortunately, the npm doesn’t install automatically we have to install it. So make sure the npm is installed in your system. 
  • The second reason is “incorrect settings of path and system variables” this is also the reason for showing that error, while installing the npm don’t forget to set the system and path variables.
  • Outdated NodeJS can also be the reason behind this error, make sure to install the latest version of NodeJS.

How to Fix “npm command not found” error in Windows

Now let’s discuss how to get rid of this “npm command not found” error.

First of all, download the NodeJS in your system and also install the npm, after that run the following command to check if the NodeJS is installed or not.

node -v

You will see an output like this.

For checking the npm use the following command.


In most of the cases npm –v command works, but after installing npm if it is still showing the “npm command not found error” then maybe you forgot to set the path and system variables.

Set the variables by following the steps below

Step 1: Go to the start menu and search environment variables and then click it. A window will open called system properties.

Step 2: Then click on the advance tab and then select environment variables and hit the enter key.

Step 3: In the system variable edit path.

Step 4: Now search the C:\Program Files\nodejs and then add it.

In case you could not find the C:\Program Files\nodejs path so add a new one.

Step 5: Go to new enter the name of the variable and provide the C:\Program Files\nodejs path for variable value and then click on the ok button. 

Now try the npm –v command hope the above way will work for you if it doesn’t so check out our next solution.

You can update NodeJs by running the following command in your window power shell.

· Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
· npm install -g npm-windows-upgrade
· npm-windows-upgrade

Hope it will work for Windows users.

How to Fix “npm command not found” error in Linux

Now let’s see how to get rid of this error in Linux.

Linux users can execute the following commands to install npm and NodeJS in their system.

Go to your activities menu and search terminal there then enter the following commands in the terminal.

$ sudo apt-get update
$ sudo apt-get install nodejs
$ sudo apt-get install npm

After executing the above commands run the node –version and npm –version commands to check if the npm and NodeJS have been installed or not.

The above sudo commands will allow the system to install npm and NodeJS. Linux users can install it easily using the above commands.

Mac users can also install the npm and NodeJS but for that, they have to take help from Homebrew.

It is a package manager for macOS, make sure it is installed in your mac systems if it is installed then execute the following command in the macOS terminal.

·        /bin/bash -c “$(curl -fsSL”

Now run these commands.

·        brew update
·        brew install node

It will install npm and NodeJS in your system to check the existence you can run the following commands.

How to check node & npm version

“node -v” and “npm -v”

These will show you the versions of NodeJS and npm.


In this tutorial, we discussed the ways to fix “npm command not found” error. First, we discussed what is an npm and its uses, then we discussed the reasons behind the occurrence of the “npm command not found” error briefly.

After that we discussed the 3 solutions, first one is to make sure the npm and NodeJS are installed then the second way is to set system and path variables, and the third way is to update your NodeJs and npm in your system.

We also saw how non-window users can fix this error, we show some commands which can help a Linux or macOS user to fix the “npm command not found” error.

That’s all for today hope you like the tutorial if you have any queries regarding this article so feel free to contact us below. Thanks for reading.

Suggested Article:

Leave a Comment