【问题标题】:Block-scoped declaration let const function class not yet supported outside strict mode in kriasoft react boiler plate块范围声明让 const 函数类在 kriasoft 反应样板中的严格模式之外尚不支持
【发布时间】:2016-11-30 03:32:21
【问题描述】:

我是 React 和 ES6 的初学者。我从样板“https://github.com/kriasoft/react-static-boilerplate”开始

如文档中所述,我运行了 npm install->node。但我收到一个错误 如"Block-scoped declaration(let, const, hunciton, class) not yet supported outside strict mode."

我尝试将“use strict”放在运行文件的顶部,但显示另一个错误“process.argv.includes is not a function”

我正在使用节点版本:4.3.0,npm:4.0.2。这是否会导致问题。 版本是否重要以支持 es6 变量,或者这是任何其他问题。

谢谢。

【问题讨论】:

    标签: javascript node.js reactjs npm ecmascript-6


    【解决方案1】:

    node v4.x 使用旧版本的 V8 (4.5),它不完全支持在草率(非严格)模式下块范围变量声明的所有场景。如果您升级到较新版本的节点,例如节点 v6.x,则不会有问题,因为那里使用的是较新版本的 V8 (5.1)。

    同样,Array.prototype.includes 在旧版本的 V8(包括节点 v4.x 中使用的版本)中的标志 (--harmony_array_includes) 后面可用。但是,从 node v6.x 开始,您可以在没有和声标志的情况下使用它。

    如需更多 ECMAScript 兼容性信息,请查看http://node.green

    【讨论】:

      猜你喜欢
      • 2017-06-17
      • 2019-09-14
      • 2017-08-16
      • 2018-04-02
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 2016-01-05
      相关资源
      最近更新 更多