Node.js 无法编译我的 .js 文件 (OSX Yosemite)
Node.js can't compile my .js files (OSX Yosemite)
我 运行 node.js 在我的 macbook pro 上,我真的不明白为什么每次我尝试通过我的终端编译一些东西时我都会收到这个错误:
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)
有人可以帮我解决这个问题吗?
卸载您从nodejs.org
安装的节点版本,然后运行:
brew update
brew uninstall node --force
brew install node
等等,您是否试图通过在节点交互 shell 中输入文件名来 运行 一个 js 文件?如果是这样,错误的原因很简单。这是因为:
/Users/francescocolonnese/Desktop/appunti.js
是无效的 javascript 代码。实际上,查看错误可以看到节点试图将 //
解释为正则表达式:
/Users/francescocolonnese
并抱怨 francescocolonnese
不是有效的正则表达式开关。
在节点 shell 中,您应该只键入有效的 javascript。如果你坚持这样做,你可以输入:
require('/Users/francescocolonnese/Desktop/appunti.js')
但这是错误的做法。而是简单地要求 node.js 到 运行 那个文件:
node -p /Users/francescocolonnese/Desktop/appunti.js
"@infomaniac - 我会尝试删除整个文件夹:/usr/local/share/systemtap/"
对我有用,谢谢!
卸载node.js
brew uninstall node
brew uninstall node --force
来自brew doctor
的输出:
正在链接 /usr/local/Cellar/node/0.12.4...
错误:无法符号链接 share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset 不可写。
移除/usr/local/share/systemtap/
$ sudo rm -rf /usr/local/share/systemtap/
重新安装node.js
brew install node
修复未链接的小桶
$ brew link node
输出:
正在链接 /usr/local/Cellar/node/0.12.4... 创建了 6 个符号链接
我 运行 node.js 在我的 macbook pro 上,我真的不明白为什么每次我尝试通过我的终端编译一些东西时我都会收到这个错误:
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)
有人可以帮我解决这个问题吗?
卸载您从nodejs.org
安装的节点版本,然后运行:
brew update
brew uninstall node --force
brew install node
等等,您是否试图通过在节点交互 shell 中输入文件名来 运行 一个 js 文件?如果是这样,错误的原因很简单。这是因为:
/Users/francescocolonnese/Desktop/appunti.js
是无效的 javascript 代码。实际上,查看错误可以看到节点试图将 //
解释为正则表达式:
/Users/francescocolonnese
并抱怨 francescocolonnese
不是有效的正则表达式开关。
在节点 shell 中,您应该只键入有效的 javascript。如果你坚持这样做,你可以输入:
require('/Users/francescocolonnese/Desktop/appunti.js')
但这是错误的做法。而是简单地要求 node.js 到 运行 那个文件:
node -p /Users/francescocolonnese/Desktop/appunti.js
"@infomaniac - 我会尝试删除整个文件夹:/usr/local/share/systemtap/"
对我有用,谢谢!
卸载node.js
brew uninstall node
brew uninstall node --force
来自brew doctor
的输出:
正在链接 /usr/local/Cellar/node/0.12.4... 错误:无法符号链接 share/systemtap/tapset/node.stp /usr/local/share/systemtap/tapset 不可写。
移除/usr/local/share/systemtap/
$ sudo rm -rf /usr/local/share/systemtap/
重新安装node.js
brew install node
修复未链接的小桶
$ brew link node
输出:
正在链接 /usr/local/Cellar/node/0.12.4... 创建了 6 个符号链接