main.js:65 Uncaught TypeError: firebase.database is not a function
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.
I have the same problem. Any progress?
Please help, this problem is literally spoiling the prestige of firebase!!!F*ck!!!!
@Jaagrav can you please post which codelab you're using? This repo is referenced by a number of codelabs.
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 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>
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.
Even I also was facing the same issue. I have removed "-app" in the below script.
After that it works fine
Have a same problem in 7.2.2 version even after issuing by remove "-app"! Plaese, help!
I also was facing the same issue. I have removed "-app" and changed to the below script.
Now it works
I don't know why google haven't fix this bug yet, its still happening in current version 7.9.0.
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.
@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. 👍
adding this worked for me
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
I recommend using: "" because it works both in Development and Production !!
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>
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.
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!
Removing -app worked for me, thx