codelab-friendlychat-web icon indicating copy to clipboard operation
codelab-friendlychat-web copied to clipboard

main.js:65 Uncaught TypeError: firebase.database is not a function

Open momisageek opened this issue 7 years ago • 19 comments

The qwiklab tutorial has an error that does not load firebase.database

The solution code does not use firebase.database --- it is using firebase.firestore. Has the syntax changed so that database is now firestore?

Following the QWIKLAB exactly will throw this error and nothing works from step 7 onward.

momisageek avatar Feb 25 '19 02:02 momisageek

I have the same problem. Any progress?

pwreng avatar Mar 31 '19 16:03 pwreng

Please help, this problem is literally spoiling the prestige of firebase!!!F*ck!!!!

Jaagrav avatar Jul 17 '19 18:07 Jaagrav

@Jaagrav can you please post which codelab you're using? This repo is referenced by a number of codelabs.

jhuleatt avatar Jul 17 '19 22:07 jhuleatt

I have also this problem with new libs.

<script src="https://www.gstatic.com/firebasejs/7.1.0/firebase-app.js"></script>                                    
<script src="https://www.gstatic.com/firebasejs/7.1.0/firebase-analytics.js"></script>

<script>

    // Your web app's Firebase configuration
    var firebaseConfig = {
        apiKey: "----------------",
        authDomain: "---------.firebaseapp.com",
        databaseURL: "https://---------.firebaseio.com",
        projectId: "----------",
        storageBucket: "---------.appspot.com",
        messagingSenderId: "-----------",
        appId: "----------------",
        measurementId: "-----------"
    };
    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);
    firebase.analytics();
    var database = firebase.database();
</script>

krishan1456 avatar Oct 05 '19 10:10 krishan1456

@krishan1456 you'll need to add this dependency as well:

firebase-database

<script src="https://www.gstatic.com/firebasejs/7.1.0/firebase-database.js"></script>

samtstern avatar Oct 07 '19 15:10 samtstern

I have had this error in my console saying function.database is not an a function. The solution for this is to remove -app in the gstatic script. Like the one below Initial Hope it helps.

joaquim-paul avatar Oct 11 '19 16:10 joaquim-paul

Even I also was facing the same issue. I have removed "-app" in the below script.

After that it works fine

girishgodage avatar Oct 13 '19 08:10 girishgodage

Have a same problem in 7.2.2 version even after issuing by remove "-app"! Plaese, help!

theneurofunk avatar Oct 28 '19 11:10 theneurofunk

I also was facing the same issue. I have removed "-app" and changed to the below script.

Now it works

Abhinav-Mani avatar Nov 05 '19 12:11 Abhinav-Mani

I don't know why google haven't fix this bug yet, its still happening in current version 7.9.0.

fademan01 avatar Feb 21 '20 10:02 fademan01

removing -app does the job but adding <script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-database.js"></script> after <script src="https://www.gstatic.com/firebasejs/7.10.0/firebase-app.js"> should fix the problem.

nedlig avatar Mar 11 '20 00:03 nedlig

@krishan1456 you'll need to add this dependency as well:

firebase-database

<script src="https://www.gstatic.com/firebasejs/7.1.0/firebase-database.js"></script>

Thanks, it worked for me. 👍

rrahool avatar Apr 05 '20 08:04 rrahool

adding this worked for me

SlyCreator avatar Jun 21 '20 15:06 SlyCreator

this helped me instead <script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-database.js"></script> i added another cdn pointing to firebase-database.js

hirwahabakaramojules avatar Aug 05 '20 08:08 hirwahabakaramojules

I recommend using: "" because it works both in Development and Production !!

Alfredo-Rojas avatar Jan 09 '21 11:01 Alfredo-Rojas

Please help, this problem is literally spoiling the prestige of firebase!!!F*ck!!!!

I take this back, I was a fool then, you just need to import the whole firebase library

<script src="https://www.gstatic.com/firebasejs/7.15.3/firebase.js"></script>

And this definitely worked for me. You can do the above stuff as well in order to import specific firebase services but my method would basically import all services from firebase. However I'd suggest you to do what @hirwahabakaramojules did, that would import only the services you want to use, this would decrease the bundle size and make your stuff load faster.

<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-database.js"></script>

Jaagrav avatar Jan 09 '21 13:01 Jaagrav

I tried it but it doesn't work for me in production, it only works in development. That is why I am importing the whole package.

Alfredo-Rojas avatar Jan 09 '21 13:01 Alfredo-Rojas

Well if importing the whole package works, then I guess it's fine, it's not really noticeable that much, if you do it using react that's where you could probably make it work. Anyway happy coding!

Jaagrav avatar Jan 09 '21 17:01 Jaagrav

Removing -app worked for me, thx

D99-1 avatar Apr 26 '21 06:04 D99-1