简体   繁体   中英

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

您需要在OS命令/ shell提示符下执行node main.js ,而不是节点repl。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM