Property 'auth' does not exist on type 'typeof import("/home/nuhutuh25/Desktop/ignition/registry/node_modules/firebase/app/dist/app/index")'.ts(2339)
I did install firebase as a dependency and also saw someone successfully writing const auth=app.auth()
but that does not work either because type FirebaseApp has no attribute auth.
I am using typescript.
CodePudding user response:
It seems you have the new Firebase Modular SDK installed (V9.0.0
) which has a new syntax unlike the older name-spaced one. If you want to keep using existing syntax you can switch to compat
version:
import firebase from "firebase/compat/app"
import "firebase/compat/auth"
I would recommend upgrading to Modular SDK because the compat libraries are a temporary solution that will be removed completely in a future major SDK version.
Try refactoring your code as shown below:
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
const app = initializeApp({...firebaseConfig});
export const auth = getAuth(app);