If you have installed Node JS or NPM in your system but the node js or npm path is not set to the system environment variable in windows. In this case, When you use node js you will see node or npm is not recognized as an internal or external command error on your command prompt. In this tutorial, we will show you how to set environment variable path in windows for node js or npm.
There are two approaches to add or set node js or npm path to the system environment variable in Windows, which are:
- Approach 1: Add Node Js Path using GUI
- Approach 2: Set Node js Path using Command Line OR Prompt
Approach 1: Add Node Js Path using GUI
Here are the steps on how to set the node js or npm path to the system environment variable in Windows 11:
- Step 1 – Open the Start menu and search for “Environment Variables”.
- Step 2 – Edit Environment Setting
- Step 3 – Edit System Environment Variable Path
- Step 4 – Set Node js or Npm path
- Step 5 – Restart Windows 11/10
Step 1 – Open the Start menu and search for “Environment Variables”.
First of all, visit your system bottom search bar and search Environment Variables; as shown below picture:
Step 2 – Environment Setting
Then Click on the environment variable setting; as shown below picture:
Step 3 – Edit System Environment Variable Path
Edit system environment variable path; as shown below picture:
Step 4 – Set Node js or Npm path
Click the “New” button and add the following paths (or similar paths depending on your installation):
- For Node.js: C:\Program Files\nodejs\node_modules.bin
- For NPM:
C:\Users\<YourUsername>\AppData\Roaming\npm
Make sure to replace <YourUsername>
with your actual Windows username.
Click “OK” to close the “Edit environment variable” dialog, “OK” again to close the “Environment Variables” dialog, and one last “OK” to close the “System Properties” dialog.
Step 5 – Restart Windows 11|10
Restart windows 10/11 system.
Approach 2: Set Node js Path using Command Line OR Prompt
Here are steps to set node js or npm path to the system environment variable in windows using command prompt or line:
- Step 1 – Open Command Prompt
- Step 2 – Set Node JS Path to Environment Variable
- Step 3 – Restart Windows 11|10
Step 1 – Open Command Prompt
First of all, visit your system bottom search bar and search cmd and then click on cmd to start your command prompt.
Step 2 – Set Node JS Path to Environment Variable
Once you have started your command prompt. Next run the following command into it to set node js path to system environment in windows:
setx path "%PATH%;C:\Program Files\nodejs"
After running this command, you will see success message into your command prompt.
Step 3 – Restart Windows 11|10
Restart Windows 10/11 system.
Conclusion
Through this tutorial, we have learned how to add node js npm path to system environment variable in windows 11/10.