56

I've been working with node.js v0.6.3, locally installed on Windows Vista at C:\Program Files\Nodejs. I recently upgraded to (by running the installer for) v0.6.6. It seemed like it worked for a while, but now if I try to run node from any directory I get a

'node' is not recognized as an internal or external command

message, though running node from C:\Program Files\Nodejs does work.

I tried rebooting, removing node, reinstalling, reinstalling 0.6.3 - nothing seems to work. I just don't get why node fails to recognize system path, though node works from its base dir?

akmozo
  • 9,829
  • 3
  • 28
  • 44
sellarafaeli
  • 1,167
  • 2
  • 9
  • 24
  • looks like you haven't added your node folder to your PATH variable. Also, you need to define a NODE_PATH variable. In *nix anyway, not sure about windows – JohnP Jan 07 '12 at 09:11

10 Answers10

126

Node is missing from the SYSTEM PATH, try this in your command line

SET PATH=C:\Program Files\Nodejs;%PATH%

and then try running node

To set this system wide you need to set in the system settings - cf - http://banagale.com/changing-your-system-path-in-windows-vista.htm

To be very clean, create a new system variable NODEJS

NODEJS="C:\Program Files\Nodejs"

Then edit the PATH in system variables and add %NODEJS%

PATH=%NODEJS%;...
First Zero
  • 21,586
  • 6
  • 46
  • 45
  • 2
    Thanks very much! Solved the problem, though I could have sworn I had checked (and manually changed, etc) the PATH variable beforehand, too. Perhaps it has a matter to do with "/" [not] appearing at end of PATH variable, and/or nodejs path needs to be BEFORE rest of path (rather than end)? Anyway, works for now and I've learned how to set path from CMD to boot, so thanks :) – sellarafaeli Jan 07 '12 at 09:37
  • 6
    I had the same problem, but removing the trailing '/' from the PATH fixed things for me for some reason. – user1103976 May 13 '13 at 05:36
  • 2
    Thanks!! Adding "C:\Program Files\Nodejs" to the PATH var in windows settings didn't work for me. Setting it like this in command line did! – Mike Bovenlander Jul 15 '16 at 11:49
46

Nodejs's installation adds nodejs to the path in the environment properties incorrectly.

By default it adds the following to the path:

C:\Program Files\nodejs\

The ending \ is unnecessary. Remove the \ and everything will be beautiful again.

Varun Achar
  • 14,781
  • 7
  • 57
  • 74
18

Go to the folder in which you have Node and NPM (such as C:\Program Files (x86)\nodejs\) and type the following:

> set path=%PATH%;%CD%
> setx path "%PATH%"

From http://www.hacksparrow.com/install-node-js-and-npm-on-windows.html

Brad
  • 159,648
  • 54
  • 349
  • 530
alessioalex
  • 62,577
  • 16
  • 155
  • 122
  • 11
    And remember in win7 you can shift-right-click a folder, or empty space inside a folder, and 'open command window here' – Plato Mar 04 '13 at 18:22
6

Everytime I install node.js it needs a reboot and then the path is recognized.

RandallTo
  • 395
  • 2
  • 11
4

Watch out for other paths ending in \ too. I had this:

...bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\nodejs\

and changed it to this:

bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\nodejs

removing the final \, but it still didn't work. The previous path, for the Web Platform Installer, had a trailing \ too. Removing that fixed the problem.

user1207577
  • 699
  • 6
  • 5
  • Thanks. Your suggestion helped me to solve the problem! I had trailing "\" in another path variable – kuldarim Jun 13 '14 at 18:55
  • Worryingly, there were loads of trailing "\"'s in the PATH variable. Including SQL Server entries and System32 entries. But this fixed my problem, so thanks! – Sethi Aug 06 '14 at 11:01
1

Just write this on your terminal (CMD) and it should work just fine:

SET PATH=C:\Program Files\Nodejs;%PATH%
Yackens
  • 29
  • 4
1

Try adding C:\Program Files\Nodejs to your PATH environment variable. The PATH environment variable allows run executables or access files within the folders specified (separated by semicolons).

On the command prompt, the command would be set PATH=%PATH%;C:\Program Files\Nodejs.

Gio Borje
  • 20,314
  • 7
  • 36
  • 50
0

Make sure nodejs in the PATH is in front of anything that uses node.

Sandersjr2
  • 57
  • 9
0

I set the NODEJS variable in the system control panel but the only thing that worked to set the path was to do it from command line as administrator.

SET PATH=%NODEJS%;%PATH%

Another trick is that once you set the path you must close the console and open a new one for the new path to be taken into account.

However for the regular user to be able to use node I had to run set path again not as admin and restart the computer

pasx
  • 2,718
  • 1
  • 34
  • 26
0

I have tried most of the above steps, but the issue didn't resolve. So I uninstalled and installed node.js and it worked for me.

Naurto san
  • 277
  • 1
  • 2
  • 14