Firebase-js-sdk: SDK version 5.8.2 with typescript : firestore is not a function

Created on 8 Feb 2019  路  5Comments  路  Source: firebase/firebase-js-sdk

Environment

  • Operating System version: Mac OS 10.13.3
  • Browser version: Chrome 71.0.3578.98
  • Firebase SDK version: 5.8.2
  • TypeScript version: 3.3.1
  • ReactJs version: 16.8.0

Problem

Steps to reproduce:

I've upgraded my project to the last firebase SDK version (5.7.x => 5.8.2) and my code doesn't work anymore. Here is the stacktrace on the screen :
image

Relevant Code

import * as firebase from "firebase/app";
import "firebase/auth";
import "firebase/database";
import "firebase/firestore";
import "firebase/functions";

// Masked because there are my personel credentials
const config = {
  ...
};

if (!firebase.apps.length) {
  firebase.initializeApp(config);
}

const settings = {/* your settings... */ timestampsInSnapshots: true};
firebase.firestore().settings(settings);

export default firebase;

I know there is a breaking API change for timestamps, as I can see in the release note here: https://firebase.google.com/support/release-notes/js#5.8.0
Even if I remove the line firebase.firestore().settings(settings);, the same error occured later in my app.

I had to do these changes in my app to make it work again:

import firebase from "@firebase/app";
import "@firebase/auth";
import "@firebase/database";
import "@firebase/firestore";
import "@firebase/functions";

// Masked because there are my personel credentials
const config = {
  ...
};

if (!firebase.apps.length) {
  firebase.initializeApp(config);
}

export default firebase;

Do you have any idea why I would have to change many code ? Is it normal ?

Here is a related issue I opened in FirebaseUI repository : https://github.com/firebase/firebaseui-web/issues/556

Thx !

core needs-attention

Most helpful comment

Hi @Feiyang1
I tried @laurentpayot solution and it worked for me !
The answer was to remove package-lock.json file and run npm install.

Thanks for all you response.
I close the issue :)

All 5 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

To continue our conversation in firebase/firebaseui-web#556:
I tried it with Typescript and couldn't reproduce. I doubt the empty d.ts files added in 5.8.0 caused your issue, but I'm also not 100% sure. I will need to see all your dependencies and the webpack configuration.
The best way for us to debug it for you is to create a repro with minimal code. Can you please create one?


Hey @devsheder. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@devsheder I'm not using TypeScript but a "firestore is not a function" error I encountered was fixed only after a full reinstall (rm -rf node_modules + rm package-lock.json + npm install).

Hi @Feiyang1
I tried @laurentpayot solution and it worked for me !
The answer was to remove package-lock.json file and run npm install.

Thanks for all you response.
I close the issue :)

Was this page helpful?
0 / 5 - 0 ratings