how can i execute a node.js in cmd prompt?

I am newbie in Node.js and started making hello world exercise. I have run into a problem, it is that I make a file with code 'console.log ("Hello World");' and saves it as a test. Then I open it in cmd and write node and then the node test, but for this answer ..... do not know why it does it, although I expect Hello World? I've tried and looking at the internet but can not find an answer to it.

I have install git and node.js.

hope someone can help me?

For example, if you save your file in `/home/toto/example.js with :

console.log('Hello World');

You just launch that by :

nodejs /home/toto/example.js
# or
cd /home/toto/
nodejs example.js

If the command nodejs is not found, test with the command node. It depend of your installation package.

node /home/toto/example.js
# or
cd /home/toto/
node example.js

1.Save the helloword.js file into a directory of your choice for example the folder "home"

2.Go to the directory in command prompt where the "helloword.js" file is by with cd:

cd home

3.You can test if the file is there by typing:

ls (mac)

dir (windows)

4.If the file is there simply write

node helloworld.js

and you should be good!:)