Solving “npm not recognized as an internal or external command” Error

In this article, we will see how to resolve the “npm not recognized as an internal or external command” error that occurs when we work or first install our node.

The error occurs when the command prompt is unable to locate the executable npm file in the system, either because the npm is not installed properly or the PATH environment variable is not set properly.

npm not recognized as an internal or external command

In this article, we will see the different causes of why the error might occur and resolve it and get npm up and running in no time.

Cause of the “npm not recognized” error

The “NPM not recognized as the internal or external command” error occurs due to the following reasons:

  1. Improper Installation of the Node: npm package is included in Nodejs, so if nodeJs is not properly installed in your system, the command prompt will not be able to detect it and throw us the error.
  2. Misconfiguration of the PATH environment variable: The PATH environment variable is a system-wide environment variable that contains the list of directories path that contains executable files. And if the path to the npm is not present there, the command prompt will not be able to detect it and it will give us an error.
  3. Incorrect version of npm : If your system has an older version of npm, it will not be compatible with the newer version of Node.js and this will give the error.

Now, by addressing any of these issues, we can solve the error and get npm to run smoothly again.

Here are some methods that we can use to solve this error.

Method 1: Install NodeJS properly

Make sure that Nodejs is installed properly on your PC. The node package manager (npm) comes with the NodeJS installer. Sometimes if NodeJS is not installed properly it can show the error.

If you have already installed it, you can uninstall it and reinstall the latest version of NodeJS from here:

Dowload Latest NodeJs Version

Get the LTS version of it and install it again in your system. After installing you can verify if the npm (node package manager) is installed correctly by using the command:

npm -v

You will get the version number in your terminal like this:

npm version

Now, if you are still getting the error, then continue with the next step.

Method 2: Adding npm to PATH Environment Variable

If you have properly installed NodeJS on your PC and still getting the error, that means the command prompt is unable to locate the npm executable file.

So, in order to access the executable, we have to add it to the PATH environment variable.

Follow these steps to add the npm path in the Environment variable:

Step1: First get the location where npm is installed in your system using the where command like this in your command prompt:

where npm
npm not recognized

Step 2: Next, we have to search for “Edit the system environment variables” in the Startup Menu Search.

Edit environment variable in windows 10

Step 3: Now in the System Properties Window, click on the Advanced tab and then click the Environment Variables button.

Edit the system environment variables

Step 4: Under System Variables, scroll down and find the Path variable. And click on Edit.

Edit environment variable for npm

Step 5: Click on New and add the path to the npm executable file (our location is “C:Program Filesnodejsnpm” as seen in Step1).

Click OK to close all windows.

add new PATH environment variable

Once you have added it successfully, you can again check npm -v and this time the error “npm not recognized as an internal or external command” will be solved.

Conclusion:

In this article, we have found out what is the cause of the “npm not recognized command” error and also learned how to solve it by reinstalling the latest version of NodeJS and adding the npm path in the PATH Enviromental Variable.


Related Article:

rm’ is not recognized as an internal or external command

(Fixed) npm ERR! missing script: start error

Fixed Error – npm ERR! missing script: dev

NVM Error – exit status 1: Access is denied – Fixed

Fixed Error: npm cannot find module error in NodeJS

How to fix “npm ERR cb() never called”

Fix error:0308010C:digital envelope routines::unsupported

Solve npm ERR! ENOENT – No Such File or Directory Error

Scroll to Top