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

179
Visualizações
Next.js & Firebase -> TypeError: Cannot read properties of undefined (reading 'apps')

what I am trying to do, is to code an auth. with NextJS and Firebase.

Now the problem appears in my firebaseClient.js, where I get the error "TypeError: Cannot read properties of undefined (reading 'apps')".

The code looks like this:

import firebase from "firebase/app";

import "firebase/auth";
import "firebase/database";

const FIREBASE_CONFIG = {
  // config files from firebase here
};

export default function firebaseClient() {
  if (!firebase.apps.length) {
    firebase.initializeApp(FIREBASE_CONFIG);
  }
}

In the console I get this error: Terminal Error

This appears on the localhost:3000: Error Page on localhost:3000

I am following this YT tutorial here , which is from 2020, so some imports, as far as I can tell, changed.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

It seems your code has firebase v8 while you have firebase v9 package and it has completely different import structures. This happen lot when you follow some tutorials with v8 and install firebase so it get latest version on default that's v9

What should you do:

1- Remove current version

npm rm firebase

2- install latest of 8.x

npm install firebase@8.9

about 4 years ago · Juan Pablo Isaza Relatório

0

I found a tutorial, and the video reproduces 100% of the errors you get with the outdated v8 firebase version. I followed the tutorial and it actually works, and when adapting the code to firebase v9, it runs again.
YouTube Video

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