【问题标题】:Attempted import error: 'react-lifecycles-compat' does not contain a default export (imported as 'reactLifecyclesCompat')尝试导入错误:“react-lifecycles-compat”不包含默认导出(导入为“reactLifecyclesCompat”)
【发布时间】:2019-05-27 12:56:36
【问题描述】:

./node_modules/reactstrap/dist/reactstrap.es.js

尝试导入错误:“react-lifecycles-compat”不包含默认导出(导入为“reactLifecyclesCompat”)。

【问题讨论】:

    标签: reactjs reactstrap


    【解决方案1】:

    只需执行npm install --save reactstrap@6.5.0 即可,无需删除任何内容。干杯!

    【讨论】:

    • reactstrap@7.0.2 已修复工件
    【解决方案2】:

    我现在遇到了同样的错误。我不是专家,但这就是它为我解决的方法。

    1. 在你的 package.json 中检查 reactstrap 的版本(我认为最新的是昨天发布的 ^7.0.0。)
    2. 在 package.json 中将其更改为 ^6.5.0
    3. 删除节点模块
    4. 重新安装依赖项

    【讨论】:

      【解决方案3】:
      1. 打开./node_modules/reactstrap/dist/reactstrap.es.js
      2. 从以下行中删除reactLifecyclesCompat,

        import reactLifecyclesCompat, { polyfill } from 'react-lifecycles-compat';

      3. 在以下行中将reactLifecyclesCompat.polyfill 更改为polyfill

        var _default = (0, reactLifecyclesCompat.polyfill)(Transition);

      【讨论】:

      • 真的很糟糕的答案!不应该是这样的..它必须有适当的解决方案
      • 这不是一个好的解决方案,但如果没有其他方法,我觉得这是最后的手段。它是 react-lifecycles-compat 中的错误吗?
      猜你喜欢
      • 2021-11-10
      • 2022-01-13
      • 2019-05-03
      • 1970-01-01
      • 1970-01-01
      • 2020-09-21
      • 2021-10-26
      • 2020-05-18
      • 2021-07-02
      相关资源
      最近更新 更多