节点应用程序要求我使用和声标志运行节点,如下所示:
node --harmony app.js
这面和声旗帜是什么?它能做什么?为什么没有它应用程序就不能运行?
我尝试过查看节点命令行选项(node --help
),但它也没有提供任何细节。节点文档也没有任何帮助。
发布于 2012-11-13 05:45:52
输入man node
会在和声标志上显示以下内容:
--harmony_typeof (enable harmony semantics for typeof)
type: bool default: false
--harmony_scoping (enable harmony block scoping)
type: bool default: false
--harmony_modules (enable harmony modules (implies block scoping))
type: bool default: false
--harmony_proxies (enable harmony proxies)
type: bool default: false
--harmony_collections (enable harmony collections (sets, maps, andweak maps))
type: bool default: false
--harmony (enable all harmony features (except typeof))
type: bool default: false
因此,--harmony
是启用所有和声功能(例如--harmony_scoping
、--harmony_proxies
等)的快捷方式。从this blog post来看,harmony似乎在语言中启用了ECMAScript 6的新功能。您的文件不能运行的原因是因为app.js
可能使用了新的ECMAScript 6标准中的非向后兼容特性(如块作用域、代理、集、映射等)。
发布于 2017-05-15 19:04:06
如果你想在老版本的NodeJS6中运行ECMAScript特性,你可以使用--harmony标志。最新版本的node支持ES6,因此不需要--harmony标志
发布于 2012-11-13 05:44:44
它在节点js:http://wiki.ecmascript.org/doku.php?id=harmony:modules中启用和声模块
https://stackoverflow.com/questions/13351965
复制相似问题