Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NODE_ENV changed for cloud run services

I had multiple nodejs services deployed on Cloud Run. The value of NODE_ENV was production initially. However, it suddenly changed to development for all the services.

  1. What could be the reason for this?
  2. How can I revert the value back to production?

Attaching the log screenshot from one of the services. enter image description here

Some additional info if it might help :

  1. The services are using Nest.js
  2. I am not setting the NODE_ENV variable during deployment
like image 796
positron Avatar asked Jan 19 '26 00:01

positron


1 Answers

We had similar issue. I tried to re-deploy cloud functions from our pipeline from the previous week using updated env variables. The deployment was successful on previous week and now it failed. We use latest as the google/cloud-sdk version.

Found this link and was able to fix the deployment: [REMOVED LINK DUE TO SPAM]

Google Cloud Build now sets GOOGLE_EXPERIMENTAL_NODEJS_NPM_BUILD_ENABLED=true as default and that triggers the NPM build automatically. Also NODE_ENV changed from production to development as a side effect. Adding GCP script to package.json didn't help as the deployment was still run as development. Cloud Build installs dev dependencies and then prunes those later. To get similar results as before, we had to set these environment variables to the cloud function deployment:

GOOGLE_NODE_RUN_SCRIPTS: ''
NODE_ENV: 'production'
like image 102
Teemu Andersén Avatar answered Jan 20 '26 17:01

Teemu Andersén



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!