Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Server Error TypeError: Cannot read properties of undefined (reading 'apps')

this is my firebase sdk version

firebase@9.0.2

this is init code of firebase i cant solve this please help me for this error




export default function  initFirebase() {
    if(!firebase.apps.length){
        firebase.initializeApp(clientCredentials)

        if(typeof window !=='undefined'){
            if('measurementId' in clientCredentials){
                firebase.analytics()
                firebase.performance()
            }
        }
        console.log('firebase was successfully init')
    }
}

How i import firebase

import firebase from 'firebase/app'

import 'firebase/firestore'
import 'firebase/storage'
import 'firebase/analytics'
import 'firebase/performance'
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You are using the new Modular SDK (V9.0.0+) which is designed to facilitate tree-shaking (removal of unused code) to make your web app as small and fast as possible. If you want to use your existing code (V8 name-spaced syntax) then you would have to change your imports to compat versions as shown below:

import firebase from 'firebase/compat/app'
import 'firebase/compat/firestore'
// import 'firebase/compat/[SERVICE_NAME]'

However, I'd recommend upgrading to the new SDK. The modular/functional syntax looks like this:

import { initializeApp } 'firebase/app'
import { getAuth } from 'firebase/auth'
import { getFirestore } from 'firebase/firestore'

const app = initializeApp({ ...firebaseConfig })

const auth = getAuth(app)
const firestore = getFirestore(app)
// other Firebase services

You don't have to check if a default Firebase app instance already exists in the modular syntax. However, if you need to list Firebase instances, you can do so using getApps():

import { getApps } from 'firebase/app'

console.log(getApps())
about 4 years ago · Juan Pablo Isaza Report

0

Below is what worked for me, the issue started after I upgraded to Firebase 9

import firebase from 'firebase/compat/app';
import * as firebaseui from 'firebaseui'
import 'firebaseui/dist/firebaseui.css'

My firebase initialization looks like below:

 let ui = firebaseui.auth.AuthUI.getInstance()
    if (!ui) {
      ui = new firebaseui.auth.AuthUI(firebase.auth())
    }
    ui.start('#firebaseui-auth-container', {
      signInFlow: isDesktop() ? 'popup' : 'redirect',
      callbacks: {
        signInSuccessWithAuthResult() {
          window.location.assign(`/home`)
          // firebase.auth().signOut()
          return false
        },
      },

...

about 4 years ago · Juan Pablo Isaza Report

0

You can't use the Firebase Auth UI library with the modular SDK yet. Check this for more details.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!