【问题标题】:TypeError: React.__spread is not a function (React 16 with babel 6)TypeError: React.__spread 不是一个函数(React 16 和 babel 6)
【发布时间】:2018-02-25 07:03:36
【问题描述】:

在 babel 中使用 node.js 如下:

require('babel-core/register')({presets: ['react']});

有以下版本:

"babel-core": "6.26.0"
"babel-preset-react": "6.24.1"

我收到上述错误。

建议?

【问题讨论】:

    标签: node.js reactjs babeljs


    【解决方案1】:

    尝试安装 babel-preset-es2015 并更新 babel 寄存器,如

    require('babel-core/register')({
      presets: ['es2015', 'react']
    });
    

    【讨论】:

    • @Daniel 似乎转换的顺序很重要,我更新了我的答案,你能试试吗,这应该在react 之前触发spread 转换
    • 谢谢,但还是一样
    • @Daniel 很有趣,不幸的是我没有更多的想法了
    猜你喜欢
    • 1970-01-01
    • 2021-07-11
    • 2020-04-17
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 2022-01-19
    • 2020-08-18
    • 2020-08-25
    相关资源
    最近更新 更多