Node.js execute Javascript file -


this newbie question , i'm sure solution easy don't it.

i downloaded node.js , put command-tool file , npm in project file.

i created file called example.js contains

console.log("hello world"); 

now open node file , type in

node example.js 

and shows me unexpected identifier.

thanks in advance.

edit:

 node -v  

shows node not defined ?? .. i'm confused.

edit2: mac ios

edit3: installed , path usr/local/bin allowed move file?

edit4: node -v works now. opened through cmd tool

edit5: okay works.. thought have work node cmd tool. quick help!

  1. open terminal
  2. go folder have example.js (use cd-command)
  3. type in terminal node example.js, press enter

you should not run node before typing node example.js


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -