Estoy aprendiendo base de fuego. Estoy usando Kubuntu 21.04. Instalé nodejs y npm usando:
sudo apt install nodejs npm una carpeta de proyecto con el archivo index.html /home/username/project/index.html .
También instalé firebase usando npm install firebase mientras estaba en la carpeta del proyecto en la terminal.
Sigo hasta el PASO 2 como se indica en https://firebase.google.com/docs/web/setup .
Mi contenido index.html-
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>User Auth</title> </head> <body> <h1>User Auth</h1> <script> // Import the functions you need from the SDKs you need import { initializeApp } from "firebase/app"; import { getAnalytics } from "firebase/analytics"; // 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: "AIzaSyC5zv8b1wfc0ykmpULeFI6tJa6Grk", authDomain: "user-auth-75223.firebaseapp.com", projectId: "user-auth-78563", storageBucket: "user-auth-78563.appspot.com", messagingSenderId: "482788408547", appId: "1:482788408547:web:89e3ecdc24f3454576c00aa", measurementId: "G-VK5D45CCJ2" }; // Initialize Firebase const app = initializeApp(firebaseConfig); const analytics = getAnalytics(app); </script> </body> </html>Pero cuando ejecuto el archivo html anterior en Chrome. Está dando error en la consola de Chrome.
SyntaxError no capturado: no se puede usar la declaración de importación fuera de un módulo
¿Probablemente se deba a que no agregó "type":"module" en package.json?
Solucioné este problema agregando esta línea
fuente: (nodo: 9374) Advertencia: para cargar un módulo ES, establezca "tipo": "módulo"