I am just starting up with firebase.
i am not sure ins and out of the firebase and based on my vaguely understanding, I have configured my app this way.
In the main Index.js file, I am requiring
const path = require('path')
const firebaseConfig = require("./src/config/firebaseConfig.js")
const firebaseDb = require("./src/helperFunctions/firebase_db.js")
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
 }
and then using this imported Db in 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
This is error in firebase TypeError: Path must be a string. Received undefined
at assertPath (path.js:28:11)
at Object.join (path.js:1236:7)
at getPath (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:6:41)
at globs.concat.map.x (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:47:59)
at Array.map ()
at module.exports.sync (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/dir-glob/index.js:47:33)
at globDirs (/Users/anilbhatia/Desktop/google-functions/functions/node_modules/globby/index.js:58:9)
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) 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?
My initial goal was to create a collection in my firebase via my express app before putting data from api routes.
Try running:
npm install [email protected]
Also you can do:
npm install
npm run build (inside functions folder.)
Then firebase deploy.
Fixed it for me.
We were able to revert the dir-glob to 2.0.0 by adding: 
"dir-glob": "2.0.0",
"globby": "8.0.0",
In the package.json dependencies.
You can do this with:
npm install [email protected] --save
npm install [email protected] --save
We then deleted the node_modules and run: npm install and deployed to Firebase
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With