Sign in

GCLOUD_PROJECT Environment Variable Missing, or my Brief Introduction to Google Serverless

TL;DR the solution to the missing variable is at the very end.

  • Realized the cloud execution environment does not have the required packages to run node.js…what?
  • I opened a cloud shell window in the GCP and used the same npm commands that the how-to guides recommend to set up the local execution environment, to install the missing node.js packages…it was not in the documentation that this should be also done in GCP shell.
  • Five hours later I have the code, the dependencies and the cloud execution environment squared away and my function has a green checkmark.
  • Then it dies. Error: process.env.GCLOUD_PROJECT is not set.
  • I google around a bit; this is a known issue with node.js 10 since 2019… what? I google a bit more, you should revert back to node.js 8…nope, node.js 8 is no longer supported and being discontinued.
  • Someone else makes a snarky remark on GitHub; you should always use the CLI to deploy the functions; the CLI will set everything up for you…
  • Under Environment Variables find Runtime environment variables
  • Add the key-value pair where Name is GCLOUD_PROJECT and the value is your Firebase Project ID (you can look this up on the Firebase console)

technologist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store