Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

432
Vistas
JS : Uncaught SyntaxError: Cannot use import statement outside a module

I am learning firebase. I am using Kubuntu 21.04. I installed nodejs and npm using :
sudo apt install nodejs npm I created a project folder with index.html file /home/username/project/index.html.
I have also installed firebase using npm install firebase while I was on project folder in terminal.
I follow upto STEP 2 as given in https://firebase.google.com/docs/web/setup.
My index.html content-

<!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>

But when I run above html file in chrome. It is giving error in chrome's console.

Uncaught SyntaxError: Cannot use import statement outside a module

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's probably because you did not add "type":"module" in package.json?

I fixed this issue by adding this line

source: (node:9374) Warning: To load an ES module, set "type": "module"

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda