How to Fix the ‘npm’ is not recognized as an internal or external command Error

The error message “‘npm’ is not recognized as an internal or external command, operable program or batch file typically occurs when the system cannot find the npm executable in its environment variables. This issue often occurs because Node.js, which includes npm, is not correctly installed or the system’s PATH variable is not set up properly.

In this article, we will discuss solutions to solve this problem.

1. Verify Node.js Installation

First, ensure that Node.js is installed on your Windows system. If Node.js is not installed, any npm commands you try to run will not work. Follow these steps to verify the installation:

  1. Open the Start Menu.
  2. Type cmd and press Enter to open the Command Prompt.
  3. In the Command Prompt, type node -v and press Enter.
  4. If Node.js is installed, you will see a version number (e.g., v14.17.5). If you do not see a version number, Node.js is not installed.

If Node.js is not installed, please visit the Node.js download page and install it.

2. Add Node.js to System PATH

If Node.js is installed on your computer but the command prompt is still showing the error, this can be caused due to Node.js not being recognized by the system. This can be done by adding it to the System PATH. Adding in the system PATH will allow the command prompt to access all the Node.js commands.

  1. Press Win + R to open the Run dialog box.
  2. Type control and press Enter.
  3. In the Control Panel, click on System and Security.
  4. Within System and Security, click on System.
  5. In the left sidebar, click on Advanced system settings.
  6. In the System Properties window, click on Environment Variables….
  7. In the Environment Variables window, find and select the Path variable under the System variables section.
  8. Click on Edit….
  9. Click on New button in the Edit Environment Variable window.
  10. Type in the path to your Node.js installation directory (e.g., C:\Program Files\nodejs\).
  11. Click on OK to close each dialog box.
  12. This command will show the installed version of Node.js if the PATH is set correctly.
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.