If this is the first time NPM is used, when we try to run a deployment either locally
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
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