I was trying to run a VueFire project. The docs mentioned that I should use a service account. So I downloaded one and put it in my project folder, added it to .gitignore
and point an environment variable to it:
# My .env file
GOOGLE_ACCOUNT_CREDENTIALS=service-account.json
I tried running it using Firebase emulator, and I got the following warning:
Failed to parse service account json file: Error: Service account object must contain a string "project_id" property.
When I checked my terminal, I see the following warning popping up when emulator is starting up:
functions: Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to /home/starleaf1/.config/firebase/starleaf1_gmail_com_application_default_credentials.json. Non-emulated services will access production using these credentials. Be careful!
It looks like the emulator ignores the .env
and looks for the service account file somewhere else. Is there a way to resolve this?
I have also tried:
/home/starleaf1/service-account.json
, but it still doesn't work..env.local
or .env.development
As it turns out, I already have a GOOGLE_CLOUD_CREDENTIALS
in my environment variables. A .env
file will not override already-existing variables. To point it to the correct file, execute this before starting Firebase Emulator Suite:
export GOOGLE_ACCOUNT_CREDENTIALS=service-account.json
When building for production, Nuxt will take into the .env
build.