1

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?

2
  • 3
    console ... not Console - though your actual code seems to use console ... console.log("HI...")ø that last character is causing node to choke Commented May 9, 2017 at 1:05
  • Thanks @JaromandaX. That was the error. It's working now. Commented May 9, 2017 at 1:39

3 Answers 3

2

There is a typo ø after console.log()

Sign up to request clarification or add additional context in comments.

Comments

1
Console.log("Hi")

to reference the global console object in Node you need to use lowercase.

Your program would therefore be console.log("Hi")

Also, the error suggests you have an extra character after the console statement. Make sure the ø character is removed.

2 Comments

It appears they have used the lower case based on the error
updated. guess the question itself contains the typo.
1

(function (exports, require, module, __filename, __dirname) { console.log("HI...")ø , there was a typo. ø

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.