React Native构建失败-“错误:尝试解析模块`react-native-firebase`”

时间:2019-06-04 00:43:19

标签: firebase react-native react-native-firebase

我正在从RN 0.55.3升级到0.57.0(手动)。

运行react-native run-iosreact-native run-android之后,我现在收到错误消息:

error: bundling failed: Error: While trying to resolve module `react-native-firebase`

我已经尝试过重新运行react-native link react-native-firebaseper this post)以及删除node_modules并重新运行yarn都没有用。

完整的错误报告:

error: bundling failed: Error: While trying to resolve module `react-native-firebase` from file `MyApp/src/screens/StarterPage.js`, the package `MyApp/node_modules/react-native-firebase/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`MyApp/node_modules/react-native-firebase/dist/index.js`. Indeed, none of these files exist:

  * `MyApp/node_modules/react-native-firebase/dist/index.js(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
  * `MyApp/node_modules/react-native-firebase/dist/index.js/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
    at ResolutionRequest.resolveDependency (MyApp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:95:15)
    at DependencyGraph.resolveDependency (MyApp/node_modules/metro/src/node-haste/DependencyGraph.js:238:485)
    at Object.resolve (MyApp/node_modules/metro/src/lib/transformHelpers.js:180:25)
    at dependencies.map.result (MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:311:29)
    at Array.map (<anonymous>)
    at resolveDependencies (MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:307:16)
    at MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:164:33
    at Generator.next (<anonymous>)
    at step (MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:266:307)
    at MyApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:266:467
 BUNDLE  [ios, dev] ../../index.js ▓▓▓▓▓▓▓▓▓▓▓░░░░░ 73.4% (796/929)::1 - - [04/Jun/2019:00:27:03 +0000] "GET /index.bundle?platform=ios&dev=true&minify=false HTTP/1.1" 200 - "-" "MyApp/79 CFNetwork/978.0.7 Darwin/18.6.0"
 BUNDLE  [ios, dev] ../../index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░ 92.7% (904/939)

我检查了所有这些文件,并将它们放在node_modules/react-native-firebase中。例如,/dist/index.js是:

import firebase from './modules/core/firebase';
export default firebase;
export * from './modules/core/firebase';
/*
 * Export App types
 */

我的package.json

{
  "name": "MyApp",
  "version": "2.1.27",
  "private": true,
  "scripts": {
    "clean:android": "./android/gradlew -p android/ clean && git clean -dfX -e *.iml android/build android/app/src",
    "bundle:android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
    "build:android:release": "yarn clean:android && yarn bundle:android && ./android/gradlew -p android/ assembleRelease",
    "run:android:release": "react-native run-android --variant=release",
    "run:android:debug": "react-native run-android",
    "test": "jest",
    "android-linux": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android",
    "eslint": "eslint —-ext .js ./src/",
    "eslint:fix": "eslint --fix ./src/",
    "flow": "flow",
    "flow-stop": "flow stop",
    "postinstall": "sed -i '' \"s/version.startsWith('iOS')/version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS')/g\" ./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js"
  },
  "dependencies": {
    "@babel/runtime": "^7.4.5",
    "@react-native-community/async-storage": "^1.3.3",
    "adm-zip": "^0.4.11",
    "axios": "^0.18.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "base-64": "^0.1.0",
    "d3-format": "^1.3.0",
    "hoist-non-react-statics": "^3.0.1",
    "lodash": "^4.17.11",
    "moment": "^2.22.2",
    "moment-timezone": "^0.5.17",
    "piexifjs": "^2.0.0-beta.7",
    "plist": "^3.0.1",
    "prop-types": "^15.6.2",
    "react": "16.5.0",
    "react-native": "0.57.0",
    "react-native-animatable": "^1.3.0",
    "react-native-camera": "^1.6.3",
    "react-native-carrier-info": "^1.0.1",
    "react-native-circular-progress": "git+https://git@github.com/bartgryszko/react-native-circular-progress.git",
    "react-native-confetti": "^0.1.0",
    "react-native-contacts": "^2.2.3",
    "react-native-country-picker-modal": "^0.5.1",
    "react-native-datepicker": "^1.7.2",
    "react-native-default-preference": "^1.3.1",
    "react-native-device-info": "^0.21.5",
    "react-native-dotenv": "^0.2.0",
    "react-native-extended-stylesheet": "^0.8.1",
    "react-native-fbsdk": "^0.8.0",
    "react-native-firebase": "5.2.0",
    "react-native-fs": "^2.13.3",
    "react-native-image-crop-picker": "^0.24.0",
    "react-native-keyboard-aware-scrollview": "^2.0.0",
    "react-native-localization": "1.0.9",
    "react-native-maps": "^0.22.1",
    "react-native-mixpanel": "^1.1.1",
    "react-native-modalbox": "^1.4.2",
    "react-native-permissions": "^1.1.1",
    "react-native-popover-tooltip": "^1.1.4",
    "react-native-popup-menu": "^0.14.0",
    "react-native-share": "^1.1.3",
    "react-native-snap-carousel": "^3.7.5",
    "react-native-sound": "^0.10.9",
    "react-native-svg": "^9.2.4",
    "react-native-svg-charts": "^5.2.0",
    "react-native-swiper": "^1.5.13",
    "react-native-version-number": "^0.3.4",
    "react-native-webview-android-file-upload": "git+https://git@github.com/andreipfeiffer/react-native-webview-android-file-upload.git",
    "react-navigation": "^1.5.11",
    "xcode": "^1.0.0"
  },
  "devDependencies": {
    "babel-jest": "24.7.1",
    "babel-preset-react-native": "5.0.2",
    "eslint-config-rallycoding": "^3.2.0",
    "flow-bin": "^0.67.1",
    "jest": "24.7.1",
    "metro-react-native-babel-preset": "0.53.1",
    "react-test-renderer": "16.5.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  }
}

我希望我的应用程序可以在模拟器(iOS)或手机(Android)上运行。

1 个答案:

答案 0 :(得分:0)

您是否尝试过重置守望者和Metro Bundler缓存?

watchman watch-del-all

react-native start --reset-cache