【问题标题】:Babel 7 Upgrading creating error: "TypeError: Cannot assign to read only property 'exports' of object '#<Object>'"Babel 7 升级创建错误:“TypeError:无法分配给对象 '#<Object>' 的只读属性 'exports'”
【发布时间】:2018-09-18 21:57:30
【问题描述】:

我正在从 babel 6 升级到 babel 7。我使用 chai、sinon 和酶的一些旧测试出现以下错误:

TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

我确实有一些代码使用“require”而不是“export”,我知道 babel 7 文档说您可能需要使用“require().default”。但这似乎没有帮助。(或者我只需要在任何地方完成默认设置并在任何错误消失之前调用它们)。其他人有这个问题的经验吗?

【问题讨论】:

  • 发布 babel 配置

标签: babeljs


【解决方案1】:

require / module.exportsimport / export尽量不要混用,保证一个一致。

【讨论】:

猜你喜欢
  • 2019-12-09
  • 2021-09-26
  • 2019-11-28
  • 2019-04-27
  • 2019-06-13
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 2019-02-08
相关资源
最近更新 更多