Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 952
TIMEX Avatar asked Aug 10 '18 07:08

TIMEX


1 Answers

The solution to this for me was

import * as gcs from '@google-cloud/storage';
const storage = new gcs.Storage();
const bucket = storage.bucket(bucketname);
like image 69
diarmuid Avatar answered Oct 20 '22 03:10

diarmuid