我需要生成项目所具有的不同目标的.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,
},
}),
},
};
这里的步骤对我不起作用:
How to fix React Native error "jest-haste-map: Haste module naming collision"?
Naming collision in react native app start
Error: jest-haste-map: Haste module naming collision:
我尝试运行rm -rf ios/build
,但最终在重新创建它时返回错误。
答案 0 :(得分:0)
有效的方法是运行以下命令:
rm ios/build/Archive/DEV.xcarchive/Products/Applications/DEV.app/assets/node_modules/react-native/package.json
答案 1 :(得分:0)
我遇到了这个问题,因为我有一个由脚本创建的名称为node_module_bak的node_module文件夹重复,请检查您是否具有相同的文件夹。
答案 2 :(得分:0)
如果您在同一主目录中有一个新项目,请尝试将其移出并保存在不同位置
答案 3 :(得分:0)
实际上,此错误仅在发生碰撞时发生。我不知道为什么会发生,但是很明显这是两者之间的冲突:
<rootDir>/node_modules/react-native/package.json
<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