I am trying to run a hello world program written in javascript in a separate file named hello.js
Currently running windows version of node.js.
The code runs perfectly in console window but how do I reference the path in windows environment.
C:\abc\zyx\hello.js in Unix I guess it is showing $ node hello.js
I'm absolutely new to Node.js Please correct me if I am doing something wrong.
I tried
> node C:\abc\zyx\hello.js ----didn't work
> C:\abc\zyx\hello.js --didn't work
UPDATE1:
Added node.exe to the folder where hello.js file is sitting.
Added path point to the folder c:\abc\zyx\ and I get an error that says
ReferenceError: hello is not defined
see contents of hello.js
setTimeout(function() { console.log('World!'); }, 2000); console.log('Hello'); UPDATE 2:
So far I have tried all these version and none of them seems to work. May be I am doing something completely wrong.
>node hello.js >$ node hello.js >node.exe hello.js >node /hello.js >node \hello.js > \node \hello.js > /node /hello.js > C:\abc\xyz\node.exe C:\abc\xyz\hello.js > C:\abc\xyz\node.exe C:/abc/xyz/hello.js > hello.js > /hello.js > \hello.js >node hello Refer to my file structure
. ├── hello.js ├── node.exe └── paths.txt RESOLVED: Instead of running node.exe, try running in command prompt with the following option and it worked.
c:\>node c:\abc\hello.js Hello World! (after 2 secs)
node hello.jsinstead ofnode hello;)