Reputation:
I'm completely new to node.js. By reading the documentation and tutorials, I managed to download and install node.js on my windows.
How do I test it and make it work?
The file test.js is saved in the same directory as node.exe and contains:
console.log('Hello World');
Openning the command-line I typed:
$ node test.js
But nothing hapenns, just:
...
Upvotes: 1
Views: 586
Reputation: 5192
Run the Node REPL by executing node via the command-line without any arguments. The reason you're not getting the expected results is probably because you're running node.exe
directly. Since you're using windows, start up CMD
and run node.exe
from there. Once you have the REPL running, try node test.js
again, and this time it will work.
Upvotes: 0
Reputation: 12340
![enter image description here][1]I have run it in nodejs shell and it is simply working
> console.log('Hello World');
Hello World
undefined
>
Also I opened nodejs command prompt not default command prompt of windows and then
node path_to_file
it is working... same output
Upvotes: -1
Reputation: 944530
You are typing node test.js
in the Node REPL not the command line. The ...
is indicating that you haven't reached the end of a valid statement yet (because you are writing shell and not JavaScript).
Run a command line with your terminal emulator of choice (probably Windows Powershell if you are using Windows).
Upvotes: 4