-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't import Storage from @google-cloud/storage #456
Comments
It seems that the correct way to import it is
However, i'm getting the error that Storage is not a constructor. Am i missing something very obvious here? |
Hi 👋 Thanks for filing an issue with us. We've temporarily disabled types on nodejs-storage because we currently have some incomplete types and it was causing issues to people that uses TypeScript. That's why the For now, please use import * as storage from '@google-cloud/storage';
const client = new storage.Storage(); We're sorry that this is causing problems on your end, we are working to get types working. |
thanks! |
import * as storage from "@google-cloud/storage"; Looks like google cloud storage doesn't work at all right now. That's not very reliable.. :/ |
@mpmckenz are you writing TypeScript or JavaScript? For TypeScript that makes sense, for plain ol' JavaScript it would still just be |
import { Storage } from '@google-cloud/storage'; or const { Storage } = require('@google-cloud/storage'); |
Unfortunately, In Node 12 the above snippets did not work in the module approach, so use below!
|
In my case (Node 14) I needed something like this:
|
Environment details
@google-cloud/storage
version: ^2.1.0Steps to reproduce
I am just trying to setup GCS in a cloud code function. I am using typescript. However when I try to
import { Storage } from '@google-cloud/storage';
i get an error thatnode_modules/@types/google-cloud__storage/index"' has no exported member 'Storage'.
If i try,
import * as Storage from '@google-cloud/storage';
I get an errorTypeError: Storage is not a constructor
. Here is my dependency file and then myindex.js
.The text was updated successfully, but these errors were encountered: