Cannot import Google Storage in TypeScript
Asked Answered
S

1

11

I am trying to import Google Storage node.js module into my Firebase Cloud functions. I am using 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');

When running $firebase deploy, I get:

TypeError: storage_1.Storage is not a constructor

Inside /lib/myfile.js

Strath answered 10/8, 2018 at 7:38 Comment(0)
D
6

The solution to this for me was

import * as gcs from '@google-cloud/storage';
const storage = new gcs.Storage();
const bucket = storage.bucket(bucketname);
Diondione answered 27/7, 2019 at 14:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.