【问题标题】:How to use react-native-firebase如何使用 react-native-firebase
【发布时间】:2020-07-27 10:41:25
【问题描述】:

我正在使用 react native firebase 指南在我的 react native 应用中安装 firebase:https://rnfirebase.io/#2-android-setup

安装成功,firebase 已连接到我的应用。

但是,当我尝试从 SDK 导入时,我收到了一个错误:找不到它:

import firebase from 'react-native-firebase'

错误显示:

Undefined Unable to resolve module 'react-native-firebase' from 'App.js'...

按照文档的指示,我只是像这样使用 npm install :

npm install --save @react-native-firebase/app

并且该软件包确实已安装。那么可能是什么原因呢?它不再是 SDK 了吗?

【问题讨论】:

    标签: firebase react-native


    【解决方案1】:

    步骤 1. 清除 watchman 手表:watchman watch-del-all

    步骤 2. 删除 node_modules 文件夹:rm -rf node_modules && npm install

    步骤 3. 重置打包程序缓存:npm start -- --reset-cache

    【讨论】:

    • 谢谢,但我为什么要这样做,为什么要删除 node_modules 文件夹?
    • 这只是因为有时,包正在使用缓存并且无法获取当前模块。最好删除 node_modules 并重新安装它,以避免任何错误。
    猜你喜欢
    • 2015-07-30
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    • 2017-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多