I have problem with loading node_modules
to one of my webpage. I have npm(node.js) installed and I want to use require()
function to init Firebase on my web and I don't why but it throw Reference error
ReferenceError: Can't find variable: require.
I am using bootstrap template and there are some files where the require()
function works, so it's weird. Below the text is the command when I call functionrequire()
. (of course Firebase is saved in node_modules using
npm firebase --save` (`../node_modules/firebase`)
also tried something like require('../firebase')
but there isn't problem):
<script>
var firebase= require('firebase');
var config = {
apiKey: "------------",
authDomain: "------.firebaseapp.com",
databaseURL: "https://-----.firebaseio.com/",
storageBucket: "gs://----.appspot.com",
};
firebase.initializeApp(config);
</script>
Can someone help me to solve my problem? Thanks a lot!
You need to load those dependencies in your document so they are available to be required
I suggest you to use a module/dependency loader for the web like RequireJS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With