Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirebaseError: Failed to load environment variables from .env

I am using Firebase to run the backend for my application. When I try to run the backend using firebase emulators:start --inspect-functions it says

Node v: 18.13.0
Firebase-tools v: ^11.18.0
Firebase-functions v: ^4.2.0

i  emulators: Starting emulators: auth, functions, storage
⚠  functions: You are running the Functions emulator in debug mode (port=9229). This means that functions will execute in sequence rather than in parallel.
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: firestore, database, hosting, pubsub
⚠  functions: Unable to fetch project Admin SDK configuration, Admin SDK behavior in Cloud Functions emulator may be incorrect.
i  ui: Emulator UI logging to ui-debug.log
i  functions: Watching "/home/ktk/code/js/sol/functions/functions" for Cloud Functions...
⚠  functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory.
✔  functions: Using node@18 from host.
⬢  functions: Failed to load function definition from source: FirebaseError: Failed to load environment variables from .env.

Things I've checked:

  • the .env does exist
  • the .env syntax is correct
  • executed chmod 777 .env to change the permissions
like image 768
OneByte Avatar asked Mar 04 '26 16:03

OneByte


2 Answers

The problem here could be that you are using reserved firebase names for your environment variable keys.You can take a look to the Firebase Config Env documentation.

Any key that starts with the word FIREBASE is reserved.

I had the same problem, and I could solve it by changing the name of my env variables.

I hope that helps. Good luck! :)

like image 177
Iván Mardini Avatar answered Mar 06 '26 05:03

Iván Mardini


I was using the "PORT" key in my .env file. This key is in the list of reserved Firebase keys.

Really wish the error message was more helpful.

like image 41
Joe Muller Avatar answered Mar 06 '26 05:03

Joe Muller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!