我有一个反应堆本地项目,当我在Windows 10环境中启动react-native run-android
时,它可以工作,但是在react-native run-ios
MacOS环境中,我的捆绑终端给出了此错误,
Loading dependency graph...(node:46534) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
Duplicate module name: react-native
Paths: /Users/tanfener/Desktop/MPP/mpp/node_modules/react-native/package.json collides with /Users/tanfener/Desktop/MPP/mpp/ios/Pods/React/package.json
This error is caused by `hasteImpl` returning the same name for different files.
at setModule (/Users/tanfener/Desktop/MPP/mpp/node_modules/metro/node_modules/jest-haste-map/build/index.js:569:17)
at workerReply (/Users/tanfener/Desktop/MPP/mpp/node_modules/metro/node_modules/jest-haste-map/build/index.js:641:9)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:46534) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:46534) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:46534) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
Duplicate module name: react-native
Paths: /Users/tanfener/Desktop/MPP/mpp/node_modules/react-native/package.json collides with /Users/tanfener/Desktop/MPP/mpp/ios/Pods/React/package.json
This error is caused by `hasteImpl` returning the same name for different files.
at setModule (/Users/tanfener/Desktop/MPP/mpp/node_modules/metro/node_modules/jest-haste-map/build/index.js:569:17)
at workerReply (/Users/tanfener/Desktop/MPP/mpp/node_modules/metro/node_modules/jest-haste-map/build/index.js:641:9)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:46534) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
我尝试了
Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'mpp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'RNI18n', :path => '../node_modules/react-native-i18n'
# Pods for mpp
target 'mppTests' do
inherit! :search_paths
# Pods for testing
end
end
答案 0 :(得分:0)
我遇到了同样的问题,可以通过以下命令来解决。
rm -rf ./node_modules && npm install
npm cache clean
npm start -- --reset-cache