问题描述
我刚开始使用Firebase.
I am just starting up with firebase.
我不确定是否可以进入和退出Firebase,并且根据我的模糊理解,我已经以这种方式配置了我的应用程序.
i am not sure ins and out of the firebase and based on my vaguely understanding, I have configured my app this way.
在主 Index.js 文件中,我需要
const path = require('path')
const firebaseConfig = require("./src/config/firebaseConfig.js")
const firebaseDb = require("./src/helperFunctions/firebase_db.js")
在这里,firebaseConfig是我配置Firebase的地方
Here, firebaseConfig is the place where I am configuring my firebase
const firebaseConfigJSON = require("./functions-config.json")
const admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.cert(firebaseConfigJSON),
databaseURL: "https://functions-firebase-43a59.firebaseio.com"
})
const db = admin.firestore()
db.settings({ timestampsInSnapshots: true });
module.exports = {
db
}
,然后在 firebaseDb
//All the operations at firebase store would be done from here
const firebaseDb = require("./../config/firebaseConfig.js")
firebaseDb.db.collection('users').add({
name: "Rohit Bhatia",
age: "24"
})
.then((response) => {
console.log("this is response", response)
})
.catch((err) => {
console.log("This is error in firebase", err)
})
由于这里的大多数代码都是单例代码,因此我一直期待所有操作都能顺利进行,直到收到以下错误为止
Since most of the code is singleton here, I was expecting everything to go smoothly until I received following error
在assertPath(path.js:28:11)
at assertPath (path.js:28:11)
在Object.join(path.js:1236:7)
at Object.join (path.js:1236:7)
在getPath(/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:6:41)
at getPath (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:6:41)
在globs.concat.map.x(/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:47:59)
at globs.concat.map.x (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:47:59)
在Array.map()
at Array.map ()
at module.exports.sync(/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:47:33)
at module.exports.sync (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:47:33)
在globDirs(/Users/anilbhatia/Desktop/google-functions/functions/node_modules/globby/index.js:58:9)
at globDirs (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/globby/index.js:58:9)
在getPattern(/Users/anilbhatia/Desktop/google-functions/functions/node_modules/globby/index.js:61:64)
at getPattern (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/globby/index.js:61:64)
at globTasks.reduce(/Users/anilbhatia/Desktop/google-functions/functions/node_modules/globby/index.js:107:19)在Array.reduce()
at globTasks.reduce (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/globby/index.js:107:19) at Array.reduce ()
有人可以帮助我弄清楚我可能做错了什么吗?还是我实际上得到了火力基地?
Can someone please help me in figuring out what could I be doing wrong? or perhaps did I actually got the firebase?
我的最初目标是在放置来自api路由的数据之前,通过我的express应用程序在firebase中创建一个集合.
My initial goal was to create a collection in my firebase via my express app before putting data from api routes.
推荐答案
我们能够通过添加以下内容将 dir-glob
还原为2.0.0:
We were able to revert the dir-glob
to 2.0.0 by adding:
"dir-glob": "2.0.0",
"globby": "8.0.0",
在package.json dependencies
中.
In the package.json dependencies
.
您可以执行以下操作:
npm install [email protected] --save
npm install [email protected] --save
然后我们删除了 node_modules
并运行: npm install
并部署到Firebase
We then deleted the node_modules
and run: npm install
and deployed to Firebase
这篇关于Firebase-TypeError:路径必须是字符串.收到未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!