【问题标题】:Google Cloud Vision API could not find a declaration fileGoogle Cloud Vision API 找不到声明文件
【发布时间】:2019-08-10 07:02:42
【问题描述】:

我正在关注这个使用 Ionic 框架和 Firebase 后端创建图像识别应用程序的教程https://www.youtube.com/watch?v=taPczl94Eow

对于这一行:

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

我不断收到错误:

Could not find a declaration file for module '@google-cloud/vision'. 
'/Users/Private/Workspace/project/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';`

我该怎么办?我已经正确安装了它。我还从 GCP 平台启用了 API 并按照他们的说明进行操作

【问题讨论】:

    标签: firebase ionic-framework google-cloud-platform google-cloud-vision


    【解决方案1】:

    我也遇到了同样的问题,所以我不得不替换这一行:

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

    对于这一行(它适用于 Typescript):

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

    我希望这适用于您的情况。

    【讨论】:

      猜你喜欢
      • 2017-07-07
      • 2019-02-05
      • 1970-01-01
      • 2017-10-20
      • 2019-08-22
      • 2023-03-02
      • 2019-03-13
      • 2016-08-24
      • 2018-08-13
      相关资源
      最近更新 更多