javascript - react native 重复错误 : Duplicated files or mocks

标签 javascript ios react-native jestjs

更新 xCode 后,我一周后面临以下错误。我无法在设备上运行应用程序。我不认为问题出在 xcode 上,因为即使我尝试在 android 设备上运行,也会出现同样的问题。

当我们使用重置选项运行 npm start 时会出现问题,同样的错误也会发生。

唯一的选择是在删除 ios 构建文件夹后在 android 设备上运行。

错误

The following files share their name; please adjust your hasteImpl:
    * <rootDir>/node_modules/react-native/package.json
    * <rootDir>/ios/build/oleo/Build/Products/Debug-iphoneos/oleo.app/assets/node_modules/react-native/package.json

Failed to construct transformer:  DuplicateError: Duplicated files or mocks. Please check the console for more info
    at setModule (/Users/murtazakanpurwala/Documents/Work/Web_Design_Dev/Clients/Oleo/OleoCW/node_modules/jest-haste-map/build/index.js:620:17)
    at workerReply (/Users/murtazakanpurwala/Documents/Work/Web_Design_Dev/Clients/Oleo/OleoCW/node_modules/jest-haste-map/build/index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 668) {
  mockPath1: 'node_modules/react-native/package.json',
  mockPath2: 'ios/build/oleo/Build/Products/Debug-iphoneos/oleo.app/assets/node_modules/react-native/package.json'
}
(node:8630) UnhandledPromiseRejectionWarning: Error: Duplicated files or mocks. Please check the console for more info
    at setModule (/Users/murtazakanpurwala/Documents/Work/Web_Design_Dev/Clients/Oleo/OleoCW/node_modules/jest-haste-map/build/index.js:620:17)
    at workerReply (/Users/murtazakanpurwala/Documents/Work/Web_Design_Dev/Clients/Oleo/OleoCW/node_modules/jest-haste-map/build/index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 668)
(node:8630) 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: 1)
(node:8630) [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.

包.json
{
  "name": "oleo",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "create-bundle-ios": "react-native bundle --platform ios --dev true --entry-file index.js --bundle-output ios/main.jsbundle",
    "create-bundle-android": "react-native bundle --platform android --dev true --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.9.0",
    "@react-native-community/netinfo": "^5.8.0",
    "@react-native-community/push-notification-ios": "^1.1.1",
    "@react-native-firebase/analytics": "^6.7.1",
    "@react-native-firebase/app": "^6.7.1",
    "@react-native-firebase/auth": "^6.7.1",
    "@react-native-firebase/firestore": "^6.7.1",
    "@react-native-firebase/messaging": "^6.7.1",
    "@react-native-firebase/storage": "^6.7.1",
    "accordion-collapse-react-native": "^0.2.10",
    "lodash": "^4.17.15",
    "md5": "^2.2.1",
    "moment": "^2.24.0",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-chooser": "^1.7.0",
    "react-native-datepicker": "^1.7.2",
    "react-native-draggable-flatlist": "^2.3.2",
    "react-native-exit-app": "^1.1.0",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-image-crop-picker": "^0.25.3",
    "react-native-image-view": "^2.1.8",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-modal": "^11.5.6",
    "react-native-pdf": "^6.1.1",
    "react-native-phone-input": "^0.2.4",
    "react-native-popup-dialog": "^0.18.3",
    "react-native-push-notification": "^3.2.1",
    "react-native-reanimated": "^1.8.0",
    "react-native-screens": "^2.7.0",
    "react-native-snackbar": "^2.2.0",
    "react-native-swiper": "^1.6.0",
    "react-native-webview": "^7.4.2",
    "react-navigation": "^4.3.8",
    "react-navigation-stack": "^1.10.3",
    "rn-fetch-blob": "^0.11.2"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/runtime": "^7.9.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.8.0",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.4",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

我已经删除了多次节点模块,也进行了全新安装,但每次都会出现问题。

最佳答案

我的原因是我有两个不同的package.json name 具有相同值的文件属性(property)。

关于javascript - react native 重复错误 : Duplicated files or mocks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61819565/

相关文章:

javascript - 如何在没有按钮的情况下在 Highcharts 中动态添加系列? ( Angular JS)

ios - UIView 内容模式在覆盖 drawRect : 时表现不同

ios - .self 在 Swift 中的结构类型之后

javascript - Require() 在 native react 中

javascript - 如何使用 React Native State 管理嵌套对象

javascript - React-router-dom goBack(),如何从另一个js文件继承prop?

javascript 无法在 mvccontrib 网格中工作

javascript - Angular 1.5 在 ng-repeat 上隐藏重复值

ios - UIApplicationProtectedDataWillBecomeUnavailable 通知 VS applicationProtectedDataWillBecomeUnavailable 委托(delegate)

react-native - 在 React Native 视频中添加字幕