为Firebase功能设置NODE_ENV [英] Setting NODE_ENV for firebase function
问题描述
我将一些firebase-queue
工作人员转移到Firebase Functions.我已经使用process.env.NODE_ENV
为工作程序设置了一些配置,具体取决于运行它们的环境.有没有一种方法可以在部署功能时设置NODE_ENV
.我知道提供这种配置选项的推荐方法是通过firebase.config.set
,我已经验证了它的预期效果,但是只是想检查是否还有一种方法可以设置NODE_ENV
.当我尝试打印出函数内部的NODE_ENV
时,它总是设置为production
.
I am moving some of my firebase-queue
workers to Firebase Functions. I have used process.env.NODE_ENV
to set some of the configuration for the workers depending on the environment in which I am running them. Is there a way to set the NODE_ENV
for the functions while deploying them. I understand that the recommended way to provide such config options is via firebase.config.set
which I have verified works as expected but just wanted to check if there is a way to set the NODE_ENV
also. When I try to print out the NODE_ENV
inside of a function, it is always set to production
.
推荐答案
Google在其
环境提供的环境变量可能会在将来的运行时版本中更改.最佳做法是,建议您不要依赖或修改尚未明确设置的任何环境变量.
Environment variables that are provided by the environment might change in future runtime versions. As a best practice, we recommend that you do not depend on or modify any environment variables that you have not set explicitly. 基本上不使用 Basically don't use 注意:本文档来自Google Cloud Functions. Firebase函数就像是围绕Google Cloud函数的包装器.检查此问题 NOTE: This documentations is from Google Cloud Functions. Firebase functions are like a wrapper around google cloud functions. Check this question 这篇关于为Firebase功能设置NODE_ENV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
NODE_ENV
.使用您自己的环境变量并进行相应的设置. NODE_ENV
. Use your own environment variables and set them accordingly.