Node.JS - How to Run Node Command from any path?

38,323

Solution 1

What happens if you run node --version? I have never tried node.js from windows but if that doesn't work there is something wrong with your paths.

What do you get when you run echo %PATH%?

Solution 2

I had the exact same problem, but in my PATH variable I had: C:\Program Files\nodejs\. After changing it to C:\Program Files\nodejs I could access it from anywhere.

Solution 3

You should check if the path C:\Program Files (x86)\nodejs is present in your %PATH. If not, add it via the system properties (persistent change). In any case, restart your command prompt, it'll reload the %PATH variable. If you're lucky, it should work now :)

Solution 4

Most likely it happens because there is no Node path in your PATH environment variable.

I see two ways to solve this

  1. Just add Node path into the end of PATH.
  2. Reinstall Node as administrator

run 7-zip (or some file manager) with administrator privileges >> browse to node-installer.msi >> open it, install node >> enjoy

Solution 5

My Sublime was working with Nodejs fine. I could press Alt-R and see the output from Node in Sublime. Then at some point I upgraded Sublime. I now have version 2.02 build 2221 And at some later point I tried Alt-R and got this infamous message

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

But it had worked, so what changed?

The steps I took to fix it were to install git bash and then

$ git clone https://github.com/tanepiper/SublimeText-Nodejs.git
$ cd SublimeText-Nodejs/
$ git checkout 095ba03344

Back in Sublime I clicked Preferences > Browse Packages. This opened up Windows Explorer with the folder:

C:\Users\me\AppData\Roaming\Sublime Text 2\Packages

I replaced the contents of the Nodejs folder with the git version. Re-started Sublime and then Alt-R sprang back into life.

Other things that turned out to be irrelevant were changing the file Nodejs.sublime-settings and tampering with system environment variables. The only thing that worked was 095ba03344 as described here https://github.com/tanepiper/SublimeText-Nodejs/pull/39

Share:
38,323
nfa379
Author by

nfa379

Updated on July 09, 2022

Comments

  • nfa379
    nfa379 almost 2 years

    I have installed the latest node.js from here . I see the %Path% variables have been set for Node.js. But, When i run node from C:\ , i get a "Node is not an recognized comman". But node command is working fine from "C:\Program Files (x86)\nodejs" path. Can i not run Node commands from C:\ or Say from an other path if i set the Env variables right? Please help. I am running a Win7 X64.

    Thank You, Faraaz

  • nfa379
    nfa379 over 12 years
    As i have said, it does not work from C:\ path but works fine from its native path at C:\Program Files(x86)\nodejs
  • nfa379
    nfa379 over 12 years
    ECHO output has the "C:\Program Files (x86)\nodejs" node path
  • nfa379
    nfa379 over 12 years
    I can see the node path if i ECHO the %PATH% in command prompt. But still no luck.
  • pomeh
    pomeh over 12 years
    Did you restart the prompt ? Does the path is separated by a semi-colon ; ?
  • nfa379
    nfa379 over 12 years
    Yes, It is. Node path is at the last of the list without the ;