I am using Firebase Functions. I set a environment variable by command:
firebase functions:config:set my.token="abcde"
I verified it by command:
firebase functions:config:get
which returns me:
{
"my": {
"token": "abcde"
}
}
in my index.js , I try to get the set token by:
const tok = functions.config().my.token
I would like to test my functions locally instructed by this document, so I run command:
firebase serve --only functions
But it gives me error:
Error from emulator. FirebaseError: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'token' of undefined
Why I can't access the token I set in environment variable of Firebase?
Double tap CTRL-C (hold down CTRL and double tap C) in the terminal running the emulator when you want to shut down the emulator and clear all the ports and processes.
This was a bug in the Firebase CLI that was fixed in version 3.17.4. Please update your firebase-tools module:
npm install -g firebase-tools
Also, don't forget to follow the instructions in the documentation and copy your configs to a local file before running the emulator:
cd functions
firebase functions:config:get > .runtimeconfig.json
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