Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!