jest-haste-map:匆忙模块命名冲突:尝试生成 .ipa 时反应原生



我需要生成我的项目具有的不同目标的.ipa,但是无论我在命令行中还是通过Xcode执行此操作,我都会继续收到以下错误:

jest-haste-map: Haste module naming collision: react-native
The following files share their name; please adjust your hasteImpl:
* <rootDir>/node_modules/react-native/package.json
* <rootDir>/ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json
Failed to construct transformer:  { Error: Duplicated files or mocks. Please check the console for more info
at setModule (/Users/danale/Projects/NFIBEngage/node_modules/jest-haste-map/build/index.js:620:17)
at workerReply (/Users/danale/Projects/NFIBEngage/node_modules/jest-haste-map/build/index.js:691:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
mockPath1: 'node_modules/react-native/package.json',
mockPath2:
'ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json' }

我已经尝试像这样创建rn-cli.config.js文件:

const blacklist = require("metro-config/src/defaults/blacklist");
module.exports = {
resolver: {
blacklistRE: blacklist([/nodejs-assets/.*/, /android/.*/, /ios/.*/])
}
};

或者这个:

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

这两种方法都不适合我。我还有一个metro.config.js

/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};

这里的步骤对我不起作用:

如何修复 React Native 错误"玩笑-匆忙-地图:匆忙模块命名冲突"?

反应本机应用启动中的命名冲突

错误:开玩笑-匆忙-映射:匆忙模块命名冲突:

我尝试运行rm -rf ios/build但最终当它被重新创建时,错误会返回。

有效的方法是运行以下命令:

rm ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json

我遇到了这个问题,因为我有重复的node_module文件夹的名称node_module_bak由脚本检查创建,检查您是否具有相同的名称。

实际上,此错误只是在发生冲突时发生的。我不知道为什么会发生这种情况,但显然这是这两者之间的碰撞:

  1. <rootDir>/node_modules/react-native/package.json
  2. <rootDir>/ios/build/[MY_BUILD_NAME]/Build/Products/Debug-iphoneos/[MY_BUILD_NAME].app/assets/node_modules/react-native/package.json

我很清楚,第二个是无用的,是碰撞的根源。 因此,当我删除它时,一切都变得正常,一切又恢复了正常。 所以使用以下命令:

$ cd [YOUR_PROJECT_ROOT_PATH]
$ rm ios/build/[MY_BUILD_NAME]/Build/Products/Debug-iphoneos/[MY_BUILD_NAME].app/assets/node_modules/react-native/package.json

如果你在同一主目录中初始化一个新项目,试着把它移出并把它们放在不同的地方