Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Hello world from node.js command prompt in windows 7

I have installed node-v0.10.13-x86.msi from nodejs.org
I have a file test.js having path (d:\BNB\test.js)

test.js:

console.log("Hello world!");

I am able to run test.js from my cmd but not from node.js command prompt refer below screenshot

From start > run > cmd (working)

enter image description here

From Node.exe (not working) enter image description here

like image 827
Satinder singh Avatar asked Jul 15 '13 12:07

Satinder singh


2 Answers

Node.exe is application that can be used to run code from file, or to be ran by it self that way it will behave like live-terminal.
Once you run node.exe like you did in second example, you will end up in node environment and everything from there is not cmd at all, but JS.

If you type: node example.js that will call node environment and will execute file in that environment.

Although, running node.exe is the same as typing node in cmd.

like image 66
moka Avatar answered Sep 19 '22 17:09

moka


in node REPL you could type

require('d:\\BNB\\test')

that shuold run your file..

like image 36
salek Avatar answered Sep 21 '22 17:09

salek