Answer the question
In order to leave comments, you need to log in
What is the error when connecting Firebase?
Hello.
I've been suffering for several days with a banal Firebase connection.
I act according to the manual and Google, but it turns out so-so.
What am I doing wrong?
Or does firebase need to import libraries in nodejs ? Beyond npm packages.
Error in the browser console: ReferenceError: require is not defined
If you expand it in more detail, it complains about the same line of imports: var firebase = require('firebase')
html clearly does not like import from the app.js file
Attempts to replace 1 line in JS with require ('firebase/app') and require('firebase/database') didn't work.
ES6 import swears even worse in the console.
HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://www.gstatic.com/firebasejs/7.14.4/firebase-app.js"></script>
<script type = "text/javascript" src = "app.js"></script>
</head>
<body>
</body>
</html>
var firebase = require('firebase')
var firebaseConfig = {
apiKey:'#####",
authDomain:'#####',
databaseURL:'#####',
projectId:'#####',
storageBucket:'#####',
messagingSenderId:'#####",
appId:'#####"'
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
let test = firebase.database()
console.log(test)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question