Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
firebase.apps.length of undefined

Environment

  • Operating System version: Windows 11
  • Browser version: Chrome
  • Firebase SDK version: 9.0.2
  • Firebase Product: database

firebase.apps.length of undefined

Issue:

I dont know what happened today morning it opened my code and it shows something like app.firestore() is not a function and shows firebase.apps.length of undefined

Code:

 import * as firebase from 'firebase/app'
 import 'firebase/firestore'
 import 'firebase/auth'
 
const app = !firebase.apps.length ? firebase.initializeApp(firebaseConfig) : firebase.app()
 
const db = app.firestore()
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The syntax for Firebase has changed in v9, as everything is now modular/functional. You can now safely get an app with:

import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs } from 'firebase/firestore';

const app = initializeApp(firebaseConfig);
const db = getFirestore(app);

I highly recommend keeping Firebase's own documentation and this upgrade guide handy.


Alternatively, you can keep using the older syntax by using the compatibility mode of the newer SDKs, by importing from the compat path.

import firebase from 'firebase/compat/app';
import 'firebase/compat/firestore';

In that case the rest of your code stays unchanged.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda