React Native 与 Expo:是否需要 firebase-admin?
React Native with Expo: is firebase-admin necessary?
我需要在身份验证过程之前获取我的 firebase 数据库。
我的 firebase 规则仅限于经过身份验证的用户进行读写。
所以我安装了 firebase-admin。
在App.js
import * as admin from 'firebase-admin';
并在初始化后
const serviceAccount = require("./pathtocredentials.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://myappdbname.firebaseio.com"
});
这是我遇到的错误:
The package at "node_modules\firebase-admin\lib\firebase-namespace.js"
attempted to import the Node standard library module "fs". It failed
because React Native does not include the Node standard library. Read
more at
https://docs.expo.io/versions/latest/introduction/faq/#can-i-use-nodejs-packages-with-expo
Failed building JavaScript bundle.
所以我搜索并..."Since your app is running inside JS VM on either iPhone or Android, the only way to access filesystem is to use react-native-fs"
我想要的只是在让用户进行身份验证之前检查我的数据库是否存在用户。我是否需要 firebase-admin 和 react-native-fs?
我需要在身份验证过程之前获取我的 firebase 数据库。 我的 firebase 规则仅限于经过身份验证的用户进行读写。
所以我安装了 firebase-admin。
在App.js
import * as admin from 'firebase-admin';
并在初始化后
const serviceAccount = require("./pathtocredentials.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://myappdbname.firebaseio.com"
});
这是我遇到的错误:
The package at "node_modules\firebase-admin\lib\firebase-namespace.js" attempted to import the Node standard library module "fs". It failed because React Native does not include the Node standard library. Read more at https://docs.expo.io/versions/latest/introduction/faq/#can-i-use-nodejs-packages-with-expo Failed building JavaScript bundle.
所以我搜索并..."Since your app is running inside JS VM on either iPhone or Android, the only way to access filesystem is to use react-native-fs"
我想要的只是在让用户进行身份验证之前检查我的数据库是否存在用户。我是否需要 firebase-admin 和 react-native-fs?