0

ローカル マシンからサービス アカウントを作成して、Google クラウドおよびサービス API と通信しようとしています。私は Mac OS を使用しています

私はこの記事に従っています

https://cloud.google.com/docs/authentication/production

端末のローカル セッションで「GOOGLE_APPLICATION_CREDENTIALS」環境変数を設定しました。

これは、Google クラウド コンソールで作成されたサービス アカウントのキー ファイルを指します。

しかし、以下のnode jsプログラムを実行するとエラーが発生します

    // Imports the Google Cloud client library.
const {Storage} = require('@google-cloud/storage');

// Instantiates a client. If you don't specify credentials when constructing
// the client, the client library will look for credentials in the
// environment.
const storage = new Storage();

try {
  // Makes an authenticated API request.
  const results = await storage.getBuckets();

  const [buckets] = results;

  console.log('Buckets:');
  buckets.forEach(bucket => {
    console.log(bucket.name);
  });
} catch (err) {
  console.error('ERROR:', err);
}

エラーは

    const results = await storage.getBuckets();
                        ^^^^^^^

SyntaxError: Unexpected identifier

ストレージ オブジェクトをインスタンス化できなかったため、資格情報の読み取り中にエラーが発生したようです。

よろしくお願いします、

サウラフ

4

1 に答える 1