Search code examples
node.jsfirebasefirebase-admin

TypeError: Cannot convert object to primitive value in firebase-admin.initializeApp()


So I've working on this project for a while and never faced any such issue. In the last commit, I made some changes in the HTML files of the project and practically no major change in my app.js. But all of a sudden, I get the following error whenever I try to run the code locally: Error message from console

Here's what the code looks like: Screenshot of the code. Line#15 is initializeApp()

I have no idea what's happening here. Please help.

PS1. This is NOT a new project. I've been working on this for over a year and haven't faced this issue ever.

PS2. I tried reverting to old commits (even the very first commit for that matter) and still got the same issue (it used to work back then).

PS3. These are not environment related issues. I set up the project on a different machine afresh and got the same issue. Another Firebase project on my machine is surprisingly working just fine.


Solution

  • After breaking my head on it for hours, I finally realized that I was initializing firebase-admin just to access the cloud firestore which I can do just with firebase. So I replace the code wherever I was accessing cloud firestore through firebase-admin with one which allows me to access firestore through firebase and voila! It worked.