Hey everyone, I’m new to Node.js and I’m having trouble getting npm to work on my Windows machine. I’ve tried installing it using Chocolatey and the official installer from nodejs.org, but I keep getting the error ‘npm is not recognized as an internal or external command’.
I’ve checked the installation directory and added it to my PATH, but still no luck. I can use npm if I open the Node.js command prompt from the Start menu, but it doesn’t work in a regular command prompt.
I’m trying to set this up so I can use Karma for testing my AngularJS code. Has anyone else run into this issue? What am I missing?
Here’s what I’ve tried so far:
# Doesn't work
npm --version
# Works fine
cd C:\Program Files\nodejs
npm --version
# Doesn't work even after adding to PATH
echo %PATH%
npm --version
I’ve encountered this issue before, and it can be frustrating. Here’s what worked for me:
First, make sure you’ve restarted your command prompt after updating the PATH. Windows sometimes requires a restart for changes to take effect.
If that doesn’t resolve the problem, try running the command prompt as an administrator. Also, double-check the environment variables to confirm that the Node.js installation directory is correctly listed.
If necessary, add the npm path manually, typically 'C:\Program Files\nodejs'. I hope this helps you get npm running smoothly!
hey man, i had the same prob. try this: open system properties, go to environment variables, then look for PATH in system variables and add C:\Program Files\nodejs\ to it. restart cmd and it should work. good luck!