Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda