【问题标题】:react native yalc nested gives : jest-haste-map: Haste module naming collision error反应原生yalc嵌套给出:jest-haste-map:Haste模块命名冲突错误
【发布时间】:2022-01-22 21:13:58
【问题描述】:

我们先看看错误:

jest-haste-map: Haste module naming collision: @stevemoretz/yoohoo
  The following files share their name; please adjust your hasteImpl:
    * <rootDir>/.yalc/@stevemoretz/yoohoo-ratchet-expo/.yalc/package-name2/package.json
    * <rootDir>/.yalc/package-name1/package.json

Failed to construct transformer:  DuplicateError: Duplicated files or mocks. Please check the console for more info
    at setModule (/Volumes/HDD/ReactNative/upgrade/store/node_modules/jest-haste-map/build/index.js:543:17)
    at workerReply (/Volumes/HDD/ReactNative/upgrade/store/node_modules/jest-haste-map/build/index.js:614:9)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Promise.all (index 27)
    at /Volumes/HDD/ReactNative/upgrade/store/node_modules/jest-haste-map/build/index.js:426:22 {
  mockPath1: '.yalc/package-name1/.yalc/@stevemoretz/yoohoo/package.json',
  mockPath2: '.yalc/package-name2/package.json'
}

发生了什么事?我在另一个 yalc 包中使用了嵌套的 yalc 包,所以出现此错误,我该如何解决?

【问题讨论】:

    标签: react-native expo yalc


    【解决方案1】:

    摆脱 .yalc 文件夹,解决了这个问题,但我们不能这样做,因为 yalc 无法正常工作?。

    但是我们可以将它从修复它的 Metro 捆绑器中排除,如何? https://stackoverflow.com/a/41963217/10268067

    所以在我们的例子中它变成:

    const exclusionList = require("metro-config/src/defaults/exclusionList");
    
    // exclusionList is a function that takes an array of regexes and combines
    // them with the default exclusions to return a single regex.
    
    module.exports = {
        resolver: {
            blacklistRE: exclusionList([/.yalc\/.*/]),
        },
    };
    

    【讨论】:

      猜你喜欢
      • 2019-06-04
      • 1970-01-01
      • 2019-06-21
      • 2020-09-19
      • 2020-03-21
      • 2018-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多