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

203
Vistas
Unexpected token error when using import command

I am trying to setup firebase and firestore for the first time

I have been trying for a few days now to get this to work with no success. Having followed all the docs on installing Firebase and firestore SDK9 modular system I still get this error.

Code

import { initializeApp } from "firebase/app";

Error:

Unexpected token '{'. import call expects exactly one argument.

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

0

Make sure that you've set module type in <script> tag if you are using import, for example:

<script type="module" src="index.js"> </script>

And if you are using nodejs you should use the latest version of nodejs and indicate module type in package.json:

{
  "name": "Testing app",
  "version": "1.0.0",
  "description": "Testing application",
  "main": "index.js",
  "type": "module"
}

about 4 years ago · Juan Pablo Isaza Denunciar

0

I have installed the latest Node Js again version v14.17.6 and installed Firebase again using npm.

I have added type: module to package.json.

First error I got was ...

TypeError: Module specifier, 'firebase/app' does not start with "/", "./", or "../".

I cleared this error by editing the index.js file and changing

import {initializeApp} from "firebase/app";

to

import {initializeApp} from "/node_modules/firebase/app";

In the index.html file I also added

    <script type="module" src="index.js"> </script>

I now get the error 'text/html' is not a valid JavaScript MIME type.

This is my package.json code

{
  "name": "firebasev9",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "keywords": [],
  "author": "IBP",
  "license": "ISC",
  "dependencies": {
    "firebase": "^9.0.2"
  }
}

I am trying to follow the setup instructions on https://firebase.google.com/docs/web/setup but they never mention either of these errors I keep getting.

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