Firestore is not a function in Vue CLI application

2019-08-16 15:08发布

import * as firebase from 'firebase'
import 'firebase/firestore'
import config from './config'

export const firebaseApp = firebase.initializeApp(config)

export const firestore = firebaseApp.firestore()

I've been battling this for the past 24hrs, I got solutions to import the firebase/firestore, but still none seems to work for me.

init.js?9adc:10 Uncaught TypeError: firebaseApp.firestore is not a function
at eval (init.js?9adc:10)
at Object.<anonymous> (renderer.js:1309)
at __webpack_require__ (renderer.js:680)
at fn (renderer.js:90)
at eval (199:3)
at Object.<anonymous> (renderer.js:2035)
at __webpack_require__ (renderer.js:680)
at fn (renderer.js:90)
at eval (CustomersTable.vue?2194:1)
at Object.<anonymous> (renderer.js:2022)

2条回答
Explosion°爆炸
2楼-- · 2019-08-16 15:39

To access the firebase service,

import * as firebase from 'firebase'
import 'firebase/firestore'
import config from './config'

export const firebaseApp = firebase.initializeApp(config)
export const firestore = firebase.firestore()
查看更多
beautiful°
3楼-- · 2019-08-16 16:03
npm install --save @firebase/firestore

fixed this for me. It broke somewhere between firebase versions 4.5.0 and 4.8.0.

查看更多
登录 后发表回答