Search code examples
javascriptfirebasecreate-react-app

Firebase `is not a function` Error with firebase 5.11.1 and greater


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?


Solution

  • 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.