简体   繁体   中英

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

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

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.

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% ?

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

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 :)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM