Reputation: 1
If I type console.log('Hello World');
in node.js it works, I get the "Hello World" message back.
But if I make a "helloworld.js" document with console.log('Hello World');
inside and then type "node helloworld.js" in node then nothing happens.
I have tried placing the script in same folder as node.js but still doesn't work.
Upvotes: 0
Views: 122
Reputation: 7117
Make sure that you're not running Nodejs.exe
because that is the REPL.
Instead you should open a regular Command Prompt window (cmd.exe
) and run the command
node helloworld.js
Make sure you run this command in the directory where the js file exists, the node application path is mapped in your environment settings.
Upvotes: 1