【问题标题】:How to fix React Native error "jest-haste-map: Haste module naming collision"?如何修复 React Native 错误“jest-haste-map:Haste 模块命名冲突”?
【发布时间】:2019-06-21 19:52:54
【问题描述】:

当我安装 react-native-popup-menu 时,我遇到了这样的错误。

这是错误代码


中寻找JS文件 E:\react-native\......\

加载依赖图...(node:9460) UnhandledPromiseRejectionWarning: 错误: jest-haste-map: Haste 模块 命名冲突:重复的模块名称:react-native 路径: E:\react-native\......\node_modules\react-native-twitter-signin\node_modules\react-native\package.json 与 E:\react-native\......\node_modules\react-native\package.json

此错误是由 hasteImpl 返回相同的名称引起的 不同的文件。 在 setModule (E:\react-native\................\node_modules\jest-haste-map\build\index.js:551:17) 在 workerReply (E:\react-native\................\node_modules\jest-haste-map\build\index.js:613:9) 在 process._tickCallback (internal/process/next_tick.js:68:7) (node:9460) UnhandledPromiseRejectionWarning: 未处理的承诺 拒绝。此错误源于在异步内部抛出 没有 catch 块的函数,或者通过拒绝一个承诺 不使用 .catch() 处理。 (拒绝 ID:2)(节点:9460)[DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。在 未来,未处理的承诺拒绝将终止 具有非零退出代码的 Node.js 进程。 (节点:9460) UnhandledPromiseRejectionWarning: 错误: jest-haste-map: Haste 模块 命名冲突:重复的模块名称:react-native 路径: E:\react-native\......\node_modules\react-native-twitter-signin\node_modules\react-native\package.json 与 E:\react-native\......\heybuddy\node_modules\react-native\package.json

此错误是由 hasteImpl 返回相同的名称引起的 不同的文件。 在 setModule (E:\react-native\................\node_modules\jest-haste-map\build\index.js:551:17) 在 workerReply (E:\react-native\................\node_modules\jest-haste-map\build\index.js:613:9) 在 process._tickCallback (internal/process/next_tick.js:68:7) (node:9460) UnhandledPromiseRejectionWarning: 未处理的承诺 拒绝。此错误源于在异步内部抛出 在没有 catch 块的情况下运行,或者通过拒绝一个承诺 不使用 .catch() 处理。 (拒绝编号:3)

我试图找到解决此错误的方法,但找不到任何解决方案。

【问题讨论】:

    标签: javascript node.js reactjs react-native jestjs


    【解决方案1】:

    我通过在文件夹的根目录中创建一个metro.config.js 文件解决了这个问题:

    module.exports = {
      resolver: {
        blacklistRE: /#current-cloud-backend\/.*/,
      },
    };
    

    【讨论】:

      【解决方案2】:

      我通过在项目根文件夹中添加一个名为“rn-cli.config.js”的新文件来解决它,内容如下。

      const blacklist = require('metro-config/src/defaults/blacklist');
      module.exports = {
          resolver: {
              blacklistRE: blacklist([
                  /node_modules\/.*\/node_modules\/react-native\/.*/,
              ])
          },
      };
      

      【讨论】:

        【解决方案3】:

        我遇到了这个问题,我创建了源文件的备份并删除了所有内容,整个文件夹。删除 node_modules 是不够的。取回文件并为软件包使用 npm install 后,它工作了。

        【讨论】:

        • 你删除了哪些“所有内容”?
        • 整个文件夹。这就是我备份源文件的原因。
        猜你喜欢
        • 1970-01-01
        • 2019-06-04
        • 1970-01-01
        • 2020-09-19
        • 2020-03-21
        • 1970-01-01
        • 2018-01-29
        • 1970-01-01
        • 2016-12-06
        相关资源
        最近更新 更多