简体   繁体   English

无法在 android 上运行 react-native

[英]Can not run react-native on android

How to fix this error on running react-native on android如何在android上运行react-native时修复此错误

Failed to construct transformer:  DuplicateError: Duplicated files or mocks. Please check the console for more info
at setModule (/home/user/HelloWorld/node_modules/jest-haste-map/build/index.js:620:17)
at workerReply (/home/user/HelloWorld/node_modules/jest-haste-map/build/index.js:691:9)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 16960) {
   mockPath1: 'node_modules/react-native/template/package.json',
   mockPath2: 'package.json'
}

This could happen when there are some changes that got cached in build.当构建中缓存了一些更改时,可能会发生这种情况。 remove android build folder by running通过运行删除android build文件夹

rm -rf android/build

then after closing Metro bundler terminal.然后在关闭 Metro bundler 终端后。 run the app again by react-native run-android .通过react-native run-android再次运行应用程序。

If the same is happening for ios remove ios/build and ios/Pods and re install Pod.如果 ios 发生同样的情况,请删除ios/buildios/Pods并重新安装 Pod。

This could happen if you have multiple checkouts of your react-native project.如果您的 react-native 项目有多个结帐,则可能会发生这种情况。 Maybe one inside another.也许一个在另一个里面。 This could result in detecting multiple package.json files.这可能会导致检测到多个 package.json 文件。 Delete the duplicate checkout.删除重复结帐。 Clean and Build.清洁和建造。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM