Skip to Content

Find the right version of gcloud when deploying your apps

Posted on One min read

When developing frontend applications with Javascript that will later be deployed in Google App Engine, it is highly recommended to use package managers like NPM.

NPM will not only help us with the Javascript packages, but it will also take care of making our lives easier with the deployment of our application.

If this is the first time NPM is used, when we try to run a deployment either locally (with npm run devserver) or in production on App Engine (with npm run deploy), it will throw an error because the variable GCLOUD_SDK is not defined.

To avoid this from happening, beforehand, we should specify the path where the Google Cloud SDK is located. However, we sometimes have several versions of the SDK in different directories and we do not know for sure which version is being used when we call the gcloud command.

To overcome this problem, there is a very simple command that always returns the correct path:

gcloud info --format="value (installation.sdk_root)"

Once the directory is obtained, we will only have to append /bin at the end, export it, and we can then execute the deploy command:

export GCLOUD_SDK=/home/user/example/google-cloud-sdk/bin
npm run deploy
comments powered by Disqus