1

I am trying to configure firebase for my react native app. I get the following error:

Attempted import error: '@firebase/app' does not contain a default export (imported as 'firebase').

I am using firebase SDK 8.2.3 and the following code to configure firebase in my app:

import firebase from 'firebase';
import '@firebase/auth';
import '@firebase/firestore';

const firebaseConfig = {
    ...
  };


if (!firebase.apps.length) {
  firebase.initializeApp(firebaseConfig);
}

export { firebase };
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
user1723583
  • 553
  • 1
  • 6
  • 18
  • That error message looks the same as you get when trying to use the old syntax on the new (v9/modular) SDKs (e.g. [here](https://stackoverflow.com/questions/68946446/how-do-i-fix-a-firebase-9-0-import-error-attempted-import-error-firebase-app)). Are you certain you're using version 8 of the SDK? Can you show how you added your dependencies? – Frank van Puffelen Sep 15 '21 at 13:44
  • In my dependencies I have: "@firebase/app": "^0.7.0", "@firebase/auth": "^0.17.2", "@firebase/util": "^1.3.0", "firebase": "8.2.3", – user1723583 Sep 15 '21 at 16:45
  • Does `import 'firebase/auth';` without `@` work ? – Dharmaraj Sep 15 '21 at 16:56
  • I still get this error for firebase/app: Attempted import error: '@firebase/app' does not contain a default export (imported as 'firebase'). – user1723583 Sep 15 '21 at 17:01

2 Answers2

1

bro just use this package

[https://rnfirebase.io/]

it is efficient and easy to use with all the use-case examples

0

You have to import firebase as below

import firebase from "firebase/app" 
Vijay Kumawat
  • 873
  • 5
  • 9