尝试访问存储桶时出现“ TypeError:gtoken_1.GoogleToken不是构造函数”

时间:2019-06-26 08:47:10

标签: firebase firebase-storage firebase-admin

我正在尝试使用Firebase Admin SDK从后端访问Firebase项目的存储,但出现以下错误:

TypeError: gtoken_1.GoogleToken is not a constructor

尝试为我的项目下载新的service-account.json文件。

const admin = require('firebase-admin');
const serviceAccount = require('./service-account.json');
const credential = admin.credential.cert(serviceAccount);
admin.initializeApp({
  credential,
  storageBucket: 'k-test-eu.appspot.com',
});

const bucket = admin.storage().bucket();
bucket.getFiles().then(console.log);

我收到以下错误消息:

'(node:30714) UnhandledPromiseRejectionWarning: TypeError: gtoken_1.GoogleToken is not a constructor
    at JWT.createGToken (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:161:27)
    at JWT.<anonymous> (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:143:33)
    at Generator.next (<anonymous>)
    at /Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:18:12)
    at JWT.refreshTokenNoCache (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:142:16)
    at JWT.<anonymous> (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/oauth2client.js:160:28)
    at Generator.next (<anonymous>)
    at /Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/oauth2client.js:22:71
(node:30714) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:30714) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

0 个答案:

没有答案