用于工作的导入firebase / app现在我收到错误(firestore不是函数)?

问题描述 投票:0回答:1

我正在使用React和Redux。我使用如下导入导入firebase:

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

一切正常,然后我提交了更改并将它们推送到GitHub。我的同事拉了代码并告诉我测试它并且它没有工作。我试图运行代码但不工作。我将导入更改为:

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

代码现在正在运行。如果有人知道这个错误的原因是什么,请你帮我理解这个问题。

firebase import google-cloud-firestore
1个回答
1
投票

我删除了package-lock.json文件

然后运行npm install

我收到了这个警告

npm WARN @firebase/firestore@1.0.6 requires a peer of @firebase/app@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/firestore@1.0.6 requires a peer of @firebase/app-types@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/auth@0.9.4 requires a peer of @firebase/app@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/functions@0.4.1 requires a peer of @firebase/app@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/functions@0.4.1 requires a peer of @firebase/app-types@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/messaging@0.3.13 requires a peer of @firebase/app@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/messaging@0.3.13 requires a peer of @firebase/app-types@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/storage@0.2.10 requires a peer of @firebase/app@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/storage@0.2.10 requires a peer of @firebase/app-types@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/auth-types@0.5.3 requires a peer of @firebase/app-types@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/auth-types@0.5.3 requires a peer of @firebase/util@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/firestore-types@1.0.3 requires a peer of @firebase/app-types@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/messaging-types@0.2.6 requires a peer of @firebase/app-types@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/storage-types@0.2.6 requires a peer of @firebase/app-types@0.x but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/storage-types@0.2.6 requires a peer of @firebase/util@0.x but none is installed. You must install peer dependencies yourself.

我重新安装了firebase

npm install --save firebase

问题解决了。没有警告或错误,它像以前一样恢复工作。

热门问题
推荐问题
最新问题