【发布时间】:2015-07-12 02:25:52
【问题描述】:
我在我的 macbook pro 上运行 node.js,我真的不明白为什么每次我尝试通过我的终端编译某些东西时都会收到这个错误:
MBPdiFrancesco:~ francescocolonnese$ node -p
> /Users/francescocolonnese/Desktop/appunti.js
SyntaxError: Invalid flags supplied to RegExp constructor 'francescocolonnese'
at new RegExp (native)
at repl:1:1
at REPLServer.defaultEval (repl.js:132:27)
at bound (domain.js:254:14)
at REPLServer.runBound [as eval] (domain.js:267:12)
at REPLServer.<anonymous> (repl.js:279:12)
at REPLServer.emit (events.js:107:17)
at REPLServer.Interface._onLine (readline.js:214:10)
at REPLServer.Interface._line (readline.js:553:8)
at REPLServer.Interface._ttyWrite (readline.js:830:14)
有人可以帮我解决这个问题吗?
【问题讨论】:
-
你能显示有问题的代码吗?
-
确定@informaniac !我将在下面发短信..但它发生在我运行节点后放在终端上的所有 .js 文件中。这是一个例子: var ciao =12; var boh = “nooo”; console.log(ciao+boh); 你可以看,代码真的很简单,但它不起作用。更复杂的代码也会发生这种情况。
-
您使用的是什么版本的 Node?我看到你的字符串周围有一些奇怪的引号 - 确保这些是常规引号;当我修复它们时它对我有用 - 但我无法重现
SyntaxError: Invalid flags supplied to RegExp constructor 'francescocolonnese'错误。您是否提供了您的节点失败的确切代码? -
是的,我刚刚尝试了几个不同的文件,但每个文件都出现相同的错误。 我正在使用节点 0.12.2。
-
顺便说一句,我更正了引号,我得到了这个: SyntaxError: Unexpected token ILLEGAL at Object.exports.createScript (vm.js:44:10) at REPLServer.defaultEval (repl.js :117:23) 绑定 (domain.js:254:14) 在 REPLServer.runBound [as eval] (domain.js:267:12) 在 REPLServer.
(repl.js:279:12) 在 REPLServer .emit (events.js:107:17) 在 REPLServer.Interface._onLine (readline.js:214:10) 在 REPLServer.Interface._line (readline.js:553:8) 在 REPLServer.Interface._ttyWrite (readline. js:830:14) 在 ReadStream.onkeypress (readline.js:109:10)
标签: javascript node.js macos terminal