Could you provide a little more information? There is no official node for Windows as far as I know, seeing as the announcement that the port was starting was only made a few weeks ago. Are you using node.js under Cygwin, or is there some other node windows fork out there (if there is, I haven't heard of it). EDIT: I didn't realize that there was a preview build available. My apologies.
– Doug StephenJul 18 '11 at 19:12

i dont know what c:> is but from the command prompt, as you said, "node c:\users\me\desktop\helloworld.js" is what worked for me.
– user1873073Dec 31 '12 at 21:24

1

I had the same problems as you, it's funny, because even today 2016, I found dozens of tutorials trying to teach nodejs but none of them teach step by step how to run the basic command besides the '$ node filename.js'. I can't understand how everybody assume that we need to use the root folder for this. Who uses the disk root to host files?
– Diego MendesJan 16 '16 at 1:27

14 Answers
14

Here are the exact steps I just took to run the "Hello World" example found at http://nodejs.org/. This is a quick and dirty example. For a permanent installation you'd want to store the executable in a more reasonable place than the root directory and update your PATH to include its location.

Works like a Charm!!! Thanks a lot. The trick is to open cmd instead of node.exe command prompt.
– MitulJul 18 '11 at 20:11

1

@Mitul - Right, this is the detail that was missing from your description -- i.e. how you were starting node -- that was preventing others from helping you. Starting node with no arguments drops you into the REPL. This is an environment for interactively executing javascript. It's not the place to kick-off the execution of a file. More here: nodejs.org/docs/v0.3.1/api/repl.html
– Wayne BurkettJul 18 '11 at 20:18

This is awful, DO NOT copy the node executable into the root of your hard drive. This is what paths are meant for, see @kcbanner's answer. Also, the Window's install of Node comes with a Node.js command prompt that has the paths properly set already if you don't want to modify your system path.
– joshperryOct 21 '13 at 17:00

2

@joshperry - I think you're slightly missing the point. The question has been heavily edited from the original, but the main problem the OP was having is that they were trying to execute a file from the REPL. Nothing about my answer is intended as a long-term installation solution, nor is that even implied. The instructions are so simple precisely to illustrate the difference between executing a .js file and opening the REPL.
– Wayne BurkettOct 22 '13 at 16:47

I installed node for windows.
There is a node.js command prompt when I search for node.js in windows 7 start menu
If you run this special command prompt, you can node anything in any location without setting up the path or copy node.exe everywhere.

All you have to do is right click the .js file on Windows and press "Open with Command Prompt"
OR
Open cmd, copy the path to the folder containing your script, and run the command "cd [paste text here]". Then do "node example.js"

The problem was that you opened the Node.js repl while everyone automatically assumed you were in the command prompt. For what it's worth you can run a javascript file from the repl with the .load command. For example:

.load c:/users/username/documents/script.js

The same command can also be used in the command prompt if you first start node inside the command prompt by entering node with no arguments (assuming node is in PATH).

I find it fascinating that 1)everyone assumed you were in the command prompt rather than repl, 2)no one seems to know about .load, and 3)this has 273 upvotes, proving that a lot of other node.js beginners are similarly confused.

Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).