Estoy siguiendo esta guía y parece que no puedo acceder a firebase correctamente. En la primera línea en app.js puedo imprimir el valor sin problema, pero la segunda línea da el error Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app). Pero se ha inicializado, ya que puedo imprimir su contenido, pero en la segunda línea no puede encontrarlos.
índice.html
<!DOCTYPE html> <html lang="en"> <head> <script src="https://www.gstatic.com/firebasejs/7.16.1/firebase.js"></script> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script type="module"> // Import the functions you need from the SDKs you need import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.8/firebase-app.js"; import { getAuth } from "https://www.gstatic.com/firebasejs/9.6.8/firebase-auth.js"; import { getFirestore } from "https://www.gstatic.com/firebasejs/9.6.8/firebase-firestore.js"; import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.8/firebase-analytics.js"; // TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries // Your web app's Firebase configuration // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: "AIzaSyD1MDRG2-93SlVo6VJcKkyeB3d-5rAoagY", authDomain: "fir-project-c7781.firebaseapp.com", projectId: "fir-project-c7781", storageBucket: "fir-project-c7781.appspot.com", messagingSenderId: "1052101364893", appId: "1:1052101364893:web:09b992d02d2b7fb1ff5874", measurementId: "G-YH5VQ2PYP3" }; // Initialize Firebase const app = initializeApp(firebaseConfig); const analytics = getAnalytics(app); </script> <script src="app.js"> </script> </head> <body> <h1>My awesome app</h1> </body> </html>y aplicación.js
console.log(firebase) const auth = firebase.auth();