The error appears on your Windows command prompt if ‘npm’ is not recognized as an internal or external command. This means that Node.js and npm (Node package manager) are not installed or the system’s PATH environment variable is not set properly.
Here we will show you some possible ways to fix npm not recognized as internal or external command. With the help of this you can solve the error.
Here are some approaches, you can try to fix this error:
- Approach 1: Check the current version of Node.js & NPM
- Approach 2: Set the npm system’s PATH environment variable
- Approach 3: Reinstall Node js and NPM
Approach 1: Check the current version of Node.js & NPM
First of all, open your Windows command prompt and use the given command to check whether Node js or npm is installed in your system or not.
node -v
npm -v
- If you have Node JS and NPM installed then use the second approach to set the PATH environment variables of NPM and Node JS to the system.
- Or if it is not installed then you can click on this link to see how to node js and npm install properly in windows.
Approach 2: Set the npm system’s PATH environment variable
If you have Node JS and NPM installed then use this approach to set the PATH environment variables of NPM and Node JS in the system:
- Step 1 – Go to Start and type “environment variables”
- Step 2 – Click Environment Variable
- Step 3 – Edit System Environment Variable Path
- Step 4 – Add Node js Npm path to environment variable
- Step 5 – Stop & Start CMD
- Step 6 – Test Node js Npm Version
Step 1 – Go to Start and type “environment variables”
First of all, Open the Start menu & search for “Environment Variables” and select “Edit the system environment variables.” like the following:
Step 2 – Click Environment Variable
Then, In the System Properties window, click the “Environment Variables” button; as shown below picture:
Step 3 – Edit System Environment Variable Path
Inside the Environment Variables menu, go to the System variables submenu, select Path, then click the Edit button.; as shown below picture:
Step 4 – Add Node js Npm path to environment variable
Click the “New” button and add the following paths (or similar paths depending on your installation):
- For Node.js:
C:\Program Files\nodejs
- 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 – Stop & Start CMD
Restart any open command prompt windows, or open a new one. Now, you should be able to run node js npm commands from any directory within the command prompt.
Step 6 – Test Node js Npm Version
Open a new Command Prompt or PowerShell window and run the following commands again to verify that Node.js and NPM are recognized:
node -v npm -v
If the output displays the node js npm version, then node js has been successfully added to the PATH variable.
Approach 3: Reinstall Node js and NPM
Still the error was not resolved. So you can use this last approach. In this, you will first have to uninstall node.js and reinstall it.
Here are the steps on how to uninstall Node.js on Windows:
- Open the Control Panel.
- Click on Programs and Features.
- Look for Node.js in the list of programs.
- Click on Uninstall.
To install Node.js on Windows 11|10, you can try these steps:
- Download the Windows installer from Nodejs.org
- Run the installer
- Follow the prompts
- Accept the license agreement
- Accept the default installation settings
- Restart your computer
- Double-click to install .msi binary files
- Verify the installation by opening a command prompt or PowerShell and entering
node -v
Conclusion
After following these steps, you should no longer see the “‘npm’ is not recognized as an internal or external command” error on Windows 11, and you can use NPM to manage your Node.js packages and projects.