【问题标题】:Cannot import Google Storage in TypeScript无法在 TypeScript 中导入 Google Storage
【发布时间】:2019-01-17 18:26:13
【问题描述】:

我正在尝试将 Google Storage node.js 模块导入我的 Firebase Cloud 函数。我正在使用打字稿。

//myfile.ts
import { Storage } from '@google-cloud/storage';

const storageInstance = new Storage({
    projectId: firebaseProjectId,
    keyFilename: "../service_accounts/" + firebaseProjectId + ".json"
});
export const bucket = storageInstance.bucket(firebaseProjectId + '.appspot.com');

运行$firebase deploy 时,我得到:

TypeError: storage_1.Storage is not a constructor

内部/lib/myfile.js

【问题讨论】:

    标签: node.js typescript firebase google-cloud-storage tslint


    【解决方案1】:

    对我来说解决方案是

    import * as gcs from '@google-cloud/storage';
    const storage = new gcs.Storage();
    const bucket = storage.bucket(bucketname);
    

    【讨论】:

      猜你喜欢
      • 2018-04-29
      • 1970-01-01
      • 2020-06-06
      • 2021-08-03
      • 2013-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-01
      相关资源
      最近更新 更多