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

190
Views
Firebase auth and firestore functionalities not working

I am using firebase for the backend part of my application. My code goes like this:

 <script type="module">
        // Import the functions you need from the SDKs you need
        import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js";
        // TODO: Add SDKs for Firebase products that you want to use
        // https://firebase.google.com/docs/web/setup#available-libraries
        import {getFirestore,collection,getDocs} from 'firebase/firestore/lite'
        // Your web app's Firebase configuration
        const firebaseConfig = {
         //My app's Config object...
        };
      
        // Initialize Firebase
        const app = initializeApp(firebaseConfig);
        
      </script>
     <script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js"></script>
     <script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-auth.js"></script>
     <script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-firestore.js"></script>

auth script:

const auth=firebase.auth();
const db=firebase.firestore();

I am getting these errors in the browser console:

Uncaught SyntaxError: Unexpected token 'export'
Uncaught SyntaxError: Cannot use import statement outside a module
Uncaught SyntaxError: Cannot use import statement outside a module
Uncaught ReferenceError: firebase is not defined at auth.js:1

Can someone pls help me!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since version 9 of its JavaScript SDK, Firebase has changed the way you call its modules. These two lines in your code are for the v8 and before SDKs:

const auth=firebase.auth();
const db=firebase.firestore();

The equivalent for v9 and above is:

const auth = getAuth();
const db = getFirestore()

I recommend checking out the Firebase documentation, which contains examples for both SDK variants, the upgrade guide for the v9 SDK, and this blog post on the modular SDK design

about 4 years ago · Santiago Trujillo 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!