[英]Error when Executing multiple lines in the Node.js REPL
我想在Nodes.js REPL模式下執行多行,如下所示。 但是我面臨以下錯誤。 如何解決這個問題呢? 非常感謝。
{
... var foo = [];
... }
語法錯誤:意外的標識符
at Object.exports.createScript (vm.js:24:10)
at REPLServer.defaultEval (repl.js:137:25)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:393: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)
如果要執行多行,則只需定義立即調用的函數表達式 ,如下所示:
(function () {
var foo = [];
})();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.