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

171
Views
Firebase Modular SDK V9.0.0+ TypeError: no se puede leer la propiedad 'aplicaciones' de firebase indefinido

Recibí este error al intentar ejecutar mi aplicación next.js. Intento de muchas maneras pero no puedo resolver esto. estoy usando base de fuego 9.0.1

 Server Error TypeError: Cannot read property 'apps' of undefined This error happened while generating the page. Any console logs will be displayed in the terminal window. Source .next\server\pages\_app.js (14:13) @ Object../firebase.js 12 | }; 13 | > 14 | const app = !firebase.apps.length | ^ 15 | ? firebase.initializeApp(firebaseConfig) 16 | : firebase.app();

Aquí está mi firebase.js

 import firebase from "firebase/app"; // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: "", authDomain: "", projectId: "", storageBucket: "", messagingSenderId: "", appId: "", measurementId: "" }; const app = !firebase.apps.length ? firebase.initializeApp(firebaseConfig) : firebase.app(); const db = app.firestore(); const auth = app.auth(); const provider = new firebase.auth.GoogleAuthProvider(); export { db, auth, provider };
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Dado que está utilizando el nuevo Modular SDK v9.0.1 que no usa firebase. espacio de nombres, debe usar getApps() en lugar de firebase.apps .

 import { initializeApp, getApps } from "firebase/app" import { getFirestore } from "firebase/firestore" import { getAuth } from "firebase/auth" const firebaseConfig = {...} if (!getApps().length) { //.... } const app = initializeApp(firebaseConfig) const db = getFirestore(app) const auth = getAuth(app) export {db, auth}

Sin embargo, no necesita verificar si Firebase ya está inicializado en este nuevo SDK. Puede obtener más información sobre la nueva sintaxis en la documentación .

Consulte también: Primeros pasos con Firebase para web

about 4 years ago · Juan Pablo Isaza Report

0

if(!firebase) está dando error debido a nuevas actualizaciones. Ahora el código se ve así

 import { initializeApp } from "firebase/app"; import { getFirestore, collection, addDoc, getDocs } from "firebase/firestore"; const firebaseConfig = { ... }; const app = initializeApp(firebaseConfig); const db = getFirestore(); export { addDoc, db, collection };

Le sugiero que vuelva a leer los documentos de Firebase, están muy actualizados y muchos códigos de tutoriales en video no funcionan. enlaces: https://firebase.google.com/docs/web/setup https://firebase.google.com/docs/build

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!