node.js - nodejs v4中默认参数的哪个和谐标志

标签 node.js ecmascript-6

我正在使用 node.js v4.0.0 并试图让一些代码工作而无需先进行转换。虽然大多数都在工作,但我无法使用

import

这可能是因为尚未完成的阶段,但我也找不到启用它的标志。我都试过了:

--harmony_modules (enable "harmony modules" (in progress))
  --harmony_array_includes (enable "harmony Array.prototype.includes" (in progress))
  --harmony_regexps (enable "harmony regular expression extensions" (in progress))
  --harmony_proxies (enable "harmony proxies" (in progress))
  --harmony_sloppy (enable "harmony features in sloppy mode" (in progress))
  --harmony_unicode_regexps (enable "harmony unicode regexps" (in progress))
  --harmony_reflect (enable "harmony Reflect API" (in progress))
  --harmony_destructuring (enable "harmony destructuring" (in progress))
  --harmony_sharedarraybuffer (enable "harmony sharedarraybuffer" (in progress))
  --harmony_atomics (enable "harmony atomics" (in progress))
  --harmony_new_target (enable "harmony new.target" (in progress))

(不用说我没有使用正则表达式... :))

虽然我得到了导入的原因,但我不明白为什么默认参数会失败,因为它们似乎已经完成,而且我找不到似乎可以处理它的标志。

是否有用于导入和默认参数的标志?

不起作用的代码是

class foo extends bar {
    constructor(options = {})
    ....
}

错误是

unexpected = illegal token

最佳答案

Node 4 使用 Chrome 45 附带的 V8 版本 - 而 V8 v4.5.103.3 不附带默认参数,即使在标志后面也是如此。默认参数位于 Chrome 49 附带的 V8 版本中,并将在 Node 6+ 中。

关于node.js - nodejs v4中默认参数的哪个和谐标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32542085/

相关文章:

node.js - Socket.io 适用于 localhost 但不适用于 Heroku 服务器

javascript - 从MongoDB获取数据并显示在前端

node.js - htaccess 适用于 www.example.com,但不适用于 example.com

node.js - 如何在 NodeJS 中刷新任意大小的 block

node.js - 如何使用 ES6 语法导入类? (没有巴别塔)

javascript - Array.of(n) 、 Array(n) 和 array = [n] 有什么区别?

javascript - Angular 2/ES6/根据属性过滤对象对象

javascript - 防止环回尝试加载 server/boot/中的某些文件

javascript - 当默认路由在 Angular 中具有参数时,无法导航到路由

javascript - 使用 ES6 语法导入一个包作为另一个包的扩展