import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const database = firebase.database();
This is my code but it gives me this error
Property 'auth' does not exist on type 'typeof import("[project path]/node_modules/firebase/app/dist/app/index")'.ts(2339) any
AngularFireAuth. user provides you an Observable<User|null> to monitor your application's authentication State. AngularFireAuth promise proxies an initialized firebase. auth. Auth instance, allowing you to log users in, out, etc.
They updated the imports with v9. The fix is easy, just update to:
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
Here's the relevant section of the docs
I think this will work, even I faced the same problem Update imports to v9 compat
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/database';
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const database = firebase.database();
Before: version 8
import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';
After: version 9 compat v9 compat packages are API compatible with v8 code
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
works for me
import firebase from 'firebase/compat/app'; import 'firebase/compat/auth'; import 'firebase/compat/firestore';
relevant section of the docs
For firebase v10 (it can work for other versions) use the following code: (worked for me)
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
firebase.initializeApp(firebaseConfig);
const auth = firebase.default.auth();
const database = firebase.default.database();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With