错误:捆绑失败-尝试解析模块“ react-native-firebase”时

时间:2018-11-12 23:18:13

标签: android reactjs firebase react-native react-native-firebase

我正在尝试使用Firebase身份验证,并且在运行react-native run-android时遇到以下错误。该错误发生在运行\ react-native \ scripts \ .. \ local-cli \ cli.js脚本时弹出的节点终端中。我正在关注initial setupandroid setupauth setup的文档。 dist /文件夹应该来自哪里?预先感谢!

错误:捆绑失败:错误:尝试从文件react-native-firebase解析模块D:\Temp\projects\app\src\components\LoginView.js时,成功找到了包D:\Temp\projects\app\node_modules\react-native-firebase\package.json。但是,该程序包本身指定了一个main无法解析的模块字段(D:\Temp\projects\app\node_modules\react-native-firebase\dist\index.js。实际上,这些文件都不存在:

  • D:\Temp\projects\app\node_modules\react-native-firebase\dist\index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  • D:\Temp\projects\app\node_modules\react-native-firebase\dist\index.js\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) 在ResolutionRequest.resolveDependency(D:\ Temp \ projects \ app \ node_modules \ metro \ src \ node-haste \ DependencyGraph \ ResolutionRequest.js:61:15) 在DependencyGraph.resolveDependency(D:\ Temp \ projects \ app \ node_modules \ metro \ src \ node-haste \ DependencyGraph.js:219:16) 在Object.resolve(D:\ Temp \ projects \ app \ node_modules \ metro \ src \ lib \ transformHelpers.js:141:30) 在dependencies.map.result(D:\ Temp \ projects \ app \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:373:31) 在Array.map() 在resolveDependencies(D:\ Temp \ projects \ app \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:369:18) 在D:\ Temp \ projects \ app \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:188:33 在Generator.next() 在步骤(D:\ Temp \ projects \ app \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:298:30) 在D:\ Temp \ projects \ app \ node_modules \ metro \ src \ DeltaBundler \ traverseDependencies.js:309:15

package.json:

{"dependencies": { "react": "^16.6.0-alpha.8af6728", "react-native": "0.57.4", "react-native-firebase": "^5.1.0" }, "peerDependencies": { "react": "^16.5.0" }, "devDependencies": { "babel-jest": "23.6.0", "jest": "23.6.0", "metro-react-native-babel-preset": "0.49.0", "react-test-renderer": "16.6.0-alpha.8af6728" }

2 个答案:

答案 0 :(得分:0)

我通过重新运行react-native link react-native-firebase来完成这项工作。成功执行此命令后,/ dist文件夹将显示在node_modules / react-native-firebase目录中。

答案 1 :(得分:0)

我遇到了这个问题,接受的答案并没有解决它。我发现缓存因 npm install firebase --save 下载失败而损坏。所以运行以下解决了这个问题:

npm uninstall react-native-firebase
yarn start --reset-cache
yarn --reset-cache
npm install react-native-firebase --save