I am trying to run firebase emulators for cloud functions, but when I type firebase emulators:start
, everytime I get this error
I tried setting up functions configuration too as suggested by => https://firebase.google.com/docs/functions/local-emulator . It generates .runtimeconfig.json file. But I am still getting the same error.
Note that I am a complete beginner in cloud functions.
I had the same issue and was able to fix it by saving my .runtimeconfig.json
file with UTF-8 encoding instead of UTF-16 encoding.
The firebase functions:config:get > .runtimeconfig.json
command seemed to save it with UTF-16 encoding by default, and the emulator does not like that for some reason.
If using VScode you can change to UTF-8 by clicking UTF-16 LE in the bottom right of the window. Then just hit save with encoding => UTF-8
I had the same issue. The .runtimeconfig.json should be in the functions directory.
So you have to do cd functions
and then firebase functions:config:get > .runtimeconfig.json
.
I think the part that is impacting you as well, is the TypeError: Cannot read property
appid of undefined
. As clarified in this issue on Github official repository, you need to run the command firebase functions:config:get > .runtimeconfig.json
, after configuring your algolia.app_id
- which relates to the second error that I mentioned - via the command firebase functions:config:set algolia.app_id="YOUR_APP_ID"
.
So, first, configure your app_id
for your Algolia and once you have than that, run the command firebase functions:config:get > .runtimeconfig.json
, so you have Algolia well configured in your Cloud Functions and the error is not faced anymore.
As noted by others, make sure to run this command "inside" functions subdir or move the generated file there.
firebase functions:config:get > .runtimeconfig.json
and that the file has correct encoding.
To verify your functions are reading all configuration correctly, "temporarily" add this line to your code
functions.logger.warn(functions.config());
And start the functions emulator. You should see a json output with all the configuration that you have set before. if anything is missing you need to set again then deploy the functions and regenerate the .runtimeconfig.json for emulator.
This is already mentioned in Firebase doc https://firebase.google.com/docs/functions/local-emulator#unix
Use the below command:
firebase functions:config:get > .runtimeconfig.json
If using Windows PowerShell, replace the above with:
firebase functions:config:get | ac .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