Reputation: 3669
With these in my package.json
"firebase": "^5.11.1",
"react-scripts": "3.0.1",
and then running react-scripts start
with this index.js
import firebase from 'firebase/app';
import 'firebase/functions';
const config = {
apiKey: "XXXXX-XXXXXXX",
authDomain: "XXXXXXXXX.firebaseapp.com",
databaseURL: "https://XXXXXXXXXX.firebaseio.com",
projectId: "XXXXXXXXX",
storageBucket: "XXXXXXX.appspot.com",
messagingSenderId: "XXXXXXXXX"
};
firebase.initializeApp(config);
const functions = firebase.functions();
I get this error.
TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_0___default.a.functions is not a function
Module../src/index.js
src/index.js:16
13 |
14 | firebase.initializeApp(config);
15 |
> 16 | const functions = firebase.functions();
17 |
what am I doing wrong?
Upvotes: 3
Views: 267
Reputation: 3669
For this bug there seemed to have been something not right in the package-lock.json file. when I deleted it and npm installed it started to work.
The version of firebase that had the issue started at 5.5.9. at 5.5.8 it worked fine.
Upvotes: 0
Reputation: 5362
You need to import firebase itself too
import firebase from 'firebase/app'
Also, after you do that initializeApp()
call make sure to initialize functions
firebase.functions()
UPDATE: In regards to your updated question's code, the code should work, please try deleting your node modules and re-running yarn or npm install (based on which package manager you use)
Upvotes: 1