PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 25, 2022

[FIXED] Why getting Uncaught TypeError: Failed to resolve module specifier "firebase". Relative references must start with either "/", "./", or "../"?

 November 25, 2022     firebase, firebase-authentication, firebase-realtime-database, javascript, module     No comments   

Issue

I have shifted my code from v8 to v9 version with modular code,but I am getting this error inspite of having installed the rollup package. My JS Code:

<script type="module">
      // TODO: Add SDKs for Firebase products that you want to use
      // https://firebase.google.com/docs/web/setup#available-libraries
      import firebase from 'firebase';
      import { initializeApp } from "firebase/app"
      import { getAuth, onAuthStateChanged } from "firebase/auth";
      import { getDatabase } from "firebase/database"
      // Your web app's Firebase configuration
      const firebaseConfig = {
      //app config
      };

      // Initialize Firebase
      const firebaseApp = initializeApp(firebaseConfig);
      const db = getDatabase(firebaseApp);
      const auth = getAuth(firebaseApp);
    </script>

The error I am getting: Uncaught TypeError: Failed to resolve module specifier "firebase". Relative references must start with either "/", "./", or "../"

I have spent considerable time but unable to find the issue.


Solution

I also had a similar error. I solved this error like this.

import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.6.3/firebase-app.js'
import { getAuth } from 'https://www.gstatic.com/firebasejs/9.6.3/firebase-auth.js'

I think you can use those URL.

I am not sure this is the proper way.



Answered By - Hyunjin Cho
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing