Search code examples
npmvisual-studio-codegoogle-cloud-platformpuppeteergoogle-vision

'GOOGLE_APPLICATION_CREDENTIALS' is not recognized


When I tape npm init start on visual studio code for working with google cloud platform, the terminal gives me this error :

'GOOGLE_APPLICATION_CREDENTIALS' n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.

Translation: "is not recognized as an internal or external command"


Solution

  • You are using a Google Cloud Library, which relies on authentication.

    Quote from the Google docs:

    GCP client libraries use a strategy called Application Default Credentials (ADC) to find your application's credentials. When your code uses a client library, the strategy checks for your credentials in the following order:

    1. First, ADC checks to see if the environment variable GOOGLE_APPLICATION_CREDENTIALS is set. If the variable is set, ADC uses the service account file that the variable points to. The next section describes how to set the environment variable.

    2. If the environment variable isn't set, ADC uses the default service account that Compute Engine, Kubernetes Engine, App Engine, and Cloud Functions provide, for applications that run on those services.

    3. If ADC can't use either of the above credentials, an error occurs.

    You need to create a service account and create a credentials file when using the service. After that, you set the GOOGLE_APPLICATION_CREDENTIALS to its path. See the docs for more information.