问题描述
节点应用程序要求我运行带有和声标志的节点,例如:
A node application has required me to run node with a harmony flag, like:
node --harmony app.js
这个和谐旗帜是什么?它做了什么以及为什么没有它可以运行应用程序?
What is this harmony flag? What does it do and why can't the app run without it?
我试过查看节点命令行选项(节点 - -help
),但它也没有提供任何细节。节点文档也没有任何帮助。
I've tried looking into node command-line options (node --help
), but it doesn't provide any details either. Node docs weren't of any help either.
推荐答案
键入 man node
在和声标志上有这个:
Typing man node
has this on the harmony flag:
--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_scoping
, - harmony_proxies
等。)来自,它似乎和谐在语言中启用了新的ECMAScript 6功能。你的文件没有和谐运行的原因是因为 app.js
可能正在使用新ECMAScript 6标准的非向后兼容功能(如块作用域,代理,集合) ,地图等。)
So --harmony
is a shortcut to enable all the harmony features (e.g. --harmony_scoping
, --harmony_proxies
, etc.) From this blog post, it seems harmony enables new ECMAScript 6 features in the language. The reason your file won't run without harmony is because app.js
is probably using non-backward compatible features from the new ECMAScript 6 standard (like block scoping, proxies, sets, maps, etc.)
这篇关于`node --harmony`有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!