I am trying to install firebase using npm on my react native app. However, after running
npm install --save firebase
and starting the app, here's the error message:
Metro has encountered an error: While trying to resolve module firebase from file /Users/jingyizhang/Documents/GitHub/my-first-project/lib/firebase.js, the package /Users/jingyizhang/Documents/GitHub/my-first-project/node_modules/firebase/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/jingyizhang/Documents/GitHub/my-first-project/node_modules/firebase/index. Indeed, none of these files exist:
*/Users/jingyizhang/Documents/GitHub/my-first-project/node_modules/firebase/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
*/Users/jingyizhang/Documents/GitHub/my-first-project/node_modules/firebase/index/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json): /Users/jingyizhang/Documents/GitHub/my-first-project/node_modules/metro/src/node-haste/DependencyGraph.js (243:17)
241 | 242 | if (error instanceof InvalidPackageError) {
243 | throw new PackageResolutionError({ | ^ 244 | packageError: error, 245 | originModulePath: from, 246 | targetModuleName: to,
ABI45_0_0RCTFatal __37-[ABI45_0_0RCTCxxBridge handleError:]_block_invoke _dispatch_call_block_and_release _dispatch_client_callout _dispatch_main_queue_drain _dispatch_main_queue_callback_4CF CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE __CFRunLoopRun CFRunLoopRunSpecific GSEventRunModal -[UIApplication _run] UIApplicationMain main start_sim 0x0
I am wondering where the problem is. Thanks in advance!