In this article, we will deeply understand this error message and the possible methods through which it can be resolved.
New to Node.js? Also Read: What is Node.js?
Why Do We Encounter This Error?
The error “node” is not recognized as an internal or external command mainly caused due to the system being unable to locate the Node executable which means our terminal or command prompt unable to find the executable file named “node”.
This may happen due to the following reasons:
- Incomplete Installation of Node.js: If Node.js is not installed properly or the version is old, this also could be one of the reasons why we may encounter this error.
- Incorrect Environment Variables: This is one of the most common reasons why this error may occur, the reason is the Node’s PATH is not properly set into the systems environment variable hence it is not recognized by the systems terminal or command prompt.
- Corrupted Node.js Version: This error can also occur when a Node.js version is corrupted which is most likely caused by some of the essential files or components being damaged due to many reasons like incorrect or incomplete installation of Node.js, disk error or hardware issues etc.
Solving ‘node’ is not recognized as an internal or external command
1. Fixing Incomplete Installation of Node.js
As we know one of the reasons for us to face this problem can be incomplete installation, so in this case the error can be solved by following steps:
1. Download the latest version of Node.js from its official website https://nodejs.org/en.
2. Run the installer into your system and Click “Next” >> “Next” >> Set your desired path >> Click “Next” >> Click “Install”.
3. Now after installation restart your computer.
4. After the restart try testing out running the command below on your terminal to check if a version returns or not. This shows that if Node.js is installed successfully or not.
2. Adding Node.js Path to Environment Variables
If the error is not solved even after re-installing Node.js then the problem could be incorrect environment variables in the system. To resolve this error, follow these simple steps:
1. On Windows, open the Start Menu with the Windows key, search for “Environment Variables” and click “Enter”.
2. Enter into “Edit the system environment variables” menu and look for ‘Environment Variables…’.
3. In the “System variables” section select the “Path” option and click “Edit”.
4. Now click on “New” and open the Node.js directory in File Explorer on the other side. You can find your Node.js directory at one of these paths.
"C:\Program Files (x86)\nodejs"
5. Copy the path from the Node.js directory and paste it into the New Variable section.
6. Click “OK” and save the changes, restart your command prompt and check the Node version again.
If the Node version is visible, the issue has been solved.
3. Repairing Corrupted Node.js Version
In case of a corrupted Node.js version here are some of the ways through which this issue can be addressed:
1. Re-install Node.js: In such cases, re-installation is one of the best ways through which this issue can be resolved, start with uninstalling all the Node.js related files and folders, download and install the latest Node.js version available on the official website.
2. Check for system issues: You can also run a disk checkup to look for any issues related to storage devices and easily identify and fix them.
3. Look for manually made changes: If you have made any manual changes to the Node.js directory or files try reverting them back to the original/default.
The error ‘node’ is not recognized as an internal or external command occurs when our system is unable to recognize the Node.js executables. This can happen due to a variety of reasons such as incomplete Node.js installation, incorrect environment variables, or corrupted Node.js version. One of the most common solutions to which can be re-installing Node.js completely from scratch. If it still doesn’t seem to be working then the error could be caused by incorrect environment variables or most probably due to a corrupted Node.js version. Detailed steps for each solution have been provided above with the help of which the error can be resolved.