首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >React Native build失败-“错误:尝试解析模块`React-native-firebase`时出错”

React Native build失败-“错误:尝试解析模块`React-native-firebase`时出错”
EN

Stack Overflow用户
提问于 2019-06-04 08:43:19
回答 1查看 6.2K关注 0票数 3

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

在运行react-native run-iosreact-native run-android之后,我现在得到以下错误:

代码语言:javascript
复制
error: bundling failed: Error: While trying to resolve module `react-native-firebase`

我已经尝试重新运行react-native link react-native-firebase (per this post)以及删除node_modules和重新运行yarn,但都不起作用。

完整的错误报告:

代码语言:javascript
复制
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为:

代码语言:javascript
复制
import firebase from './modules/core/firebase';
export default firebase;
export * from './modules/core/firebase';
/*
 * Export App types
 */

我的package.json

代码语言:javascript
复制
{
  "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)或我的手机(安卓)上运行。

EN

回答 1

Stack Overflow用户

发布于 2019-06-04 08:50:10

您是否尝试过重置watchman和Metro Bundler缓存?

watchman watch-del-all

react-native start --reset-cache

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56436070

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档