firebase.firestore() is not a function when trying to initialize Cloud Firestore

前端 未结 21 1460
独厮守ぢ
独厮守ぢ 2020-12-01 02:45

When I try to initialize Firebase Cloud Firestore, I ran into the following error:

Uncaught TypeError: WEBPACK_IMPORTED_MODULE_0_firebase

21条回答
  •  -上瘾入骨i
    2020-12-01 03:21

    I had same Error and tried to follow the official website but did not work. Then I googled error and landed in this post.

    I tried:

    import * as firebase from 'firebase';
    import 'firebase/firestore';
    

    However, it did not work for me but I added /firebase to the first line import * as firebase from 'firebase/firebase'; and everything is working perfectly.

    It also works with require:

    const firebase = require("firebase/firebase");
    // Required for side-effects
    require("firebase/firestore");
    

提交回复
热议问题