Monday 8 May 2017

Console.log giving error in Node.js

I am newbie to Node. I have installed Node on my nginx server. Created a folder namely test in the root. Inside the test folder I have created a js file namely test.js.

I have written a simple Console.log("Hi").

Now in the terminal I am running the following code:

node test.js

I am getting following error.

/root/test/test.js:1
(function (exports, require, module, __filename, __dirname) { console.log("HI...")ΓΈ
                                                                                  ^
SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)

Any idea what I am missing?



via TechBee

No comments:

Post a Comment