gpt4 book ai didi

node.js - 无法在 TypeScript 中导入 Google Storage

转载 作者:搜寻专家 更新时间:2023-10-30 20:38:41 24 4
gpt4 key购买 nike

我正在尝试将 Google Storage node.js 模块导入到我的 Firebase Cloud 函数中。我正在使用 typescript 。

//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 不是构造函数

/lib/myfile.js 中

最佳答案

我的解决方案是

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

关于node.js - 无法在 TypeScript 中导入 Google Storage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51781405/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com