TIMEX
TIMEX

Reputation: 271674

Cannot import Google Storage in TypeScript

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

Upvotes: 11

Views: 3469

Answers (1)

diarmuid
diarmuid

Reputation: 343

The solution to this for me was

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

Upvotes: 6

Related Questions