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

141
Views
how to solve 'SyntaxError: Cannot use import statement outside a module'

in my script.js

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.4.1/firebase-app.js";
 import { getDatabase, ref, set, child, get } from "https://www.gstatic.com/firebasejs/9.4.1/firebase-database.js";


 // Initialize Firebase
 const app = initializeApp(firebaseConfig);
 const db = getDatabase(app);
 const dbRef = ref(db);

is showing error SyntaxError: Cannot use import statement outside a module how do I solve this

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It sounds like you're using import in a script, not a module. The distinction is in how the environment was told to load the file.

In a browser, you need type="module" on the script tag:

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

More on MDN.

On Node.js, you need "type": "module" in your package.json or the .mjs extension, see the Node.js documentation for details.

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!