skip to Main Content

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

2

Answers


  1. This may happen for any reason:

    Double-check that the file contains lines like:

    FIREBASE_API_KEY=XYZ123 
    FIREBASE_AUTH_DOMAIN=mydomain.firebaseapp.com 
    FIREBASE_DATABASE_URL=https://mydatabase.firebaseio.com 
    etc...
    

    Check that the .env file is indexed in your gitignore or .npmignore. Environment variables will not be loaded if the file is ignored.
    And ensure there are no spaces around the = when setting the variables.

    Login or Signup to reply.
  2. 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! 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search