How to resolve ‘node’ is not recognized as an internal or external command error after installing Node.js ?

Encountering the error message ‘node’ is not recognized as an internal or external command after installing Node.js can be frustrating, especially when you’re eager to start working on your project. This error usually means that your system cannot find the Node.js executable because the path to it is not set correctly in your system’s environment variables. This guide will walk you through resolving this issue step-by-step on both Windows and macOS.

'node' is not recognized as an internal or external command,
operable program or batch file.

This is the most common error and it is very simple to resolve this. It might be a case that the user might have properly installed node from the official node website. But sometimes, the reason is that the path variable is not defined in your system. So to properly define a path variable and resolve this error, follow these simple steps:

Table of Content

  • Verify Node.js Installation
  • Reinstall Node.js
  • Add Node.js to System PATH

Verify Node.js Installation

First, ensure that Node.js has been installed correctly. You can verify this by navigating to the directory where Node.js was installed (typically C:\Program Files\nodejs). Check for the presence of the node.exe file in this directory.

Reinstall Node.js

If the above steps don’t work, consider reinstalling Node.js:

Uninstall Node.js

  • Open Control Panel.
  • Go to Programs > Programs and Features.
  • Find and uninstall Node.js.

Reinstall Node.js

  • Download the latest Node.js installer from the official Node.js website.
  • Run the installer and ensure that the option to add Node.js to the PATH is checked.

Add Node.js to System PATH

If Node.js is installed but the command is still not recognized, it means the system PATH variable is not set correctly. Follow these steps to add Node.js to your PATH. Step-by-Step Solution is as:

Step 1:

Open the Environment Variables option in your Control Panel. (Go to Control Panel -> System and Security ->System -> Advanced System Settings-> Environment Variables ->User Variables or System Variables.)

Step 2:

Select the variable named Path. A dialogue box named Edit user variable will appear. In the variable value option inside that dialogue box, paste the complete path of the location where node.js is installed in your system.Then click on OK.

Step 3:

Restart the command prompt again and now verify by typing node-v in the command prompt. It will now display the version of the node which you’ve installed from the internet .