javascript - React Native DuplicateError:重复的文件或模拟
问题描述
更新 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
属性值相同。
推荐阅读
- javascript - 获取在 LUIS 上添加的句子
- android - 使用 recyclerview 滚动 coordinatorLayout 中的 Android 抖动错误(instagram 也有此错误)
- c++ - 何时在 C++ 中的嵌套类上使用 Pimpl 模式,反之亦然?
- javascript - 如何在异常捕获中获取数据库引用?
- botframework - Microsoft 团队免费帐户:此卡操作已禁用,因为 BOT 已被您的管理员阻止
- windows - 如何执行 ubuntu.exe 并使用一个命令导航到直接文件夹?
- google-cloud-platform - 在 GCP 上调整永久磁盘大小时,如何触发文件系统调整大小?
- ruby-on-rails - Rails:如何删除默认版本的捆绑程序?
- java - 声纳的 Spring Boot 配置问题
- python - 数组用零填充