Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'auth' does not exist on type 'typeof import..." firebase/auth

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

like image 271
Beatriz Mantoani Avatar asked Sep 11 '21 01:09

Beatriz Mantoani


People also ask

What is AngularFireAuth?

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.


4 Answers

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

like image 143
misterbastean Avatar answered Oct 29 '22 02:10

misterbastean


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';
like image 9
Sanket Patil Avatar answered Oct 29 '22 02:10

Sanket Patil


works for me import firebase from 'firebase/compat/app'; import 'firebase/compat/auth'; import 'firebase/compat/firestore';

relevant section of the docs

like image 1
nh-helperf Avatar answered Oct 29 '22 00:10

nh-helperf


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();
like image 1
Hilati Ashref Avatar answered Oct 29 '22 00:10

Hilati Ashref