Intruder
Intruder

Reputation: 145

node repl showing error

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

Upvotes: -1

Views: 876

Answers (1)

mscdex
mscdex

Reputation: 106726

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

Upvotes: 3

Related Questions