我对node.js还不熟悉。我刚刚在我的Windows机器上完成了安装,目前正在按照tutorialspoint上的教程学习。在安装完成后,我被告知需要创建一个名为main.js的文件,并将下面的代码放入该文件中。
/* Hello, World! program in node.js */
console.log("Hello, World!")
我使用Node.js解释器执行了main.js文件,输入命令$ node main.js,但是出现了以下错误。
SyntaxError: Unexpected identifierat 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)
请帮我一下,谢谢。
node main.js
,而不是从 shell 中运行。 - vp_arth