I'm trying to run cloud function on my local system for which I need to set some env variables. I'm following docs for env and for local development docs.
I'm trying to run my project via the following command:
node node_modules/@google-cloud/functions-framework --target=syncingredients --env-vars-file=.env.yaml
Where my .env.yaml
looks like:
API_KEY: key
AUTH_DOMAIN: project.firebaseapp.com
Seems like --env-vars-file aren't supported with functions framework (https://github.com/GoogleCloudPlatform/functions-framework-nodejs/issues/38)
I would recommend the workaround suggested by relymd-djk:
pre-req:
npm install env-cmd
npm install yaml2json
modifying the package.json scripts section with:
"scripts": {
"start":"yaml2json .env.yaml >.env.json && env-cmd -r ./.env.json functions-framework --target=syncingredients",
"deploy": "gcloud functions deploy myFunction --entry-point syncingredients --trigger-http --runtime nodejs16 --env-vars-file ./.env.yaml"
}
to run the function:
npm start
Thanks to ClumsyPuffin for highlighting that it isn't an available feature so I went for dotenv
Changed the file to .env
:
API_KEY="key"
AUTH_DOMAIN="project.firebaseapp.com"
And used the following command to run the function locally
node -r dotenv/config node_modules/@google-cloud/functions-framework --target=syncingredients
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