-1

Iam a newbie to node.js and when I tried to run the Hello world application it showed error.I created a main.js file and using node repl i called the $ node main.js.It resulted in error

SyntaxError: Unexpected identifier
at Object.exports.createScript (vm.js:24:10)
at REPLServer.defaultEval (repl.js:221:25)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:412:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:826:14)

After that I tried the same with normal command prompt.I traversed to main.js and executed node main.js then it showed the output.But in examples, the JS is executed using the node repl.Its totally confusing.If I try $ node in repl it also shows error. Please help

1 Answer 1

3

You need to execute node main.js at your OS command/shell prompt, not the node repl.

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

2 Comments

ok i got that ...when i tried $ node in repl it showed the same error.Is it like that?
The REPL is for executing javascript, not executing commands (well, short of the few special REPL commands that start with a .) or external scripts.

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.