If you've ever come across the "the term node is not recognized..." error, you know how frustrating it can be.
node: The term node is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ node
+ ~~~~
+ CategoryInfo : ObjectNotFound: (node: String) [], CommandNotFoundException
+ FullyQualifiedErrorId: CommandNotFoundException
In the command prompt, this error message looks like this: 'node is not recognized as an internal or external command, operable program, or batch file'. This error usually points to one of two primary reasons:
- Case 1: Node.js may not be installed on your computer.
- Case 2: The system's Path environment variable might not include the Node path.
In this simple guide, we will find the solutions to rectify the mentioned issue on the Windows platform.
Solution 1: Install Node JS
The "The term node is not recognized as the name of a cmdlet, function, script file, or operable program" error may occur if we do not have NodeJS installed on our system.
First, open the Node.js official website and download the LTS installer as shown below.
After downloading, install Node.js using the installer.
Once the installer is done, let’s try checking if the error is resolved or not by verifying the node version on cmd/PowerShell.
node --version
If all steps are done correctly, then this command should return the version of the node installed in our system.
If it still returns the "'node' is not recognized as an internal or external command, operable program, or batch file" error, move forward to Solution 2.
Solution 2: Updating Windows PATH for node
In case you've already installed Node.js but continue to encounter this error, the next step involves modifying the node path within the Windows environment variables. Incorporating node into your system's Path variable guarantees the recognition of this tool through the command line interface. This issue predominantly emerges when the system is unable to pinpoint the installation location of Node JS. We will rectify this by appending Node JS to the path. Follow these steps to successfully complete the process:
Click on your search icon beside the windows icon and type "Environment Variables".
- Click on the first option "Edit the system Environment Variables". A System Properties window will open. Click on "Environment Variables".
- Select Path and click on "Edit".
- Click "New" and add the location of the NodeJS installation.
- To discover the installation location of Node.js, navigate to the installation directory for Node.js. Begin by accessing your C Drive, then locate the 'Program Files' folder. Inside this folder, you will come across the 'Node.js' folder. Enter this folder. This is how my NodeJS folder looks:
- You have to copy this path and add it as an environment variable by pasting it in the edit environment variable dialogue box:
- Your "Edit environment variables" dialogue box will look something like this:
- Click "Ok" to close all the dialogue boxes, and you are almost done! Make sure you restart your terminal to apply the changes. Now try to run a node command, and it should work without any errors.
Conclusion
Resolving the "Node is not recognized..." error can be a simple task with the right guidance. By verifying the proper installation and configuration of Node.js, you can ensure a seamless development journey. In case you're unable to locate the Node.js installation directory, it's advisable to perform a reinstallation, which can potentially save you significant time. Happy coding!