Skip to content
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

Could not find a declaration file for module '@google-cloud/vision' #3

Open
honghu215 opened this issue Feb 12, 2019 · 4 comments
Open

Comments

@honghu215
Copy link

Hi,

Thanks for sharing.

there's an error with the following command

import * as admin from '@google-cloud/vision';

Could not find a declaration file for module '@google-cloud/vision'. '/Users/honghu/Projects/ionic/demos/GoogleFunctions/functions/node_modules/@google-cloud/vision/src/index.js' implicitly has an 'any' type.
Try npm install @types/google-cloud__vision if it exists or add a new declaration (.d.ts) file containing declare module '@google-cloud/vision';

I have dependency @google-cloud/vison: "^0.24.0" in package.json

How should I solve this issue, thanks?

@sal-g
Copy link

sal-g commented Aug 10, 2019

How did you solve it?

@rzvAmmar
Copy link

A quick hacky fix was to reimplement the function in javascript.

@nwaughachukwuma
Copy link

@rzvAmmar can you share your fix, please.

@rzvAmmar
Copy link

rzvAmmar commented Nov 7, 2019

@rzvAmmar can you share your fix, please.

const admin = require('firebase-admin');
const functions = require('firebase-functions');
const vision = require('@google-cloud/vision')

admin.initializeApp()

exports.fileUploaded = functions.storage.object().onFinalize(async (object) => {
const fileBucket = object.bucket; // The Storage bucket that contains the file.
const filePath = object.name; // File path in the bucket.
const contentType = object.contentType; // File content type.
const metageneration = object.metageneration; // Number of times metadata has been generated. New objects have a value of 1.index.js

const client = new vision.ImageAnnotatorClient();
const fileName = "gs://" + fileBucket + "/" + filePath;
console.log("File URI: ", fileName);

// Performs text detection on the local file
client.textDetection(fileName)
.then(results => {
    var text = results[0].fullTextAnnotation.text;
    name = filePath.split("/")[1]
    admin.database().ref("files/" + name + "/text").set(text);
})
.catch(err => {
    console.error('ERROR:', err);
});

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants