无法使用Angular导入Google Vision API
我试图用Google Vision创建一个angular项目,但angular拒绝编译它。这是我的app.component.ts文件无法使用Angular导入Google Vision API,angular,google-vision,Angular,Google Vision,我试图用Google Vision创建一个angular项目,但angular拒绝编译它。这是我的app.component.ts文件 import { Component } from '@angular/core'; import * as vision from '@google-cloud/vision'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: [
import { Component } from '@angular/core';
import * as vision from '@google-cloud/vision';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'Hello';
ngOnInit() {
const client = new vision.ImageAnnotatorClient();
}
}
这是我在构建应用程序时遇到的错误
ERROR in ./node_modules/@grpc/grpc-js/build/src/channel.js
Module not found: Error: Can't resolve '../../package' in 'f:\temp\project\node_modules\@grpc\grpc-js\build\src'
任何帮助都将不胜感激,提前谢谢。您的package.json文件中是否有
google cloud/vision
?确保软件包已安装。如果您使用的是npm,您只需从终端运行npm安装--将@google cloud/vision
保存在项目文件夹中即可安装。什么是@grpc
?这是google vision所需的模块。我不知道它是做什么的。你在使用CLI吗?是的。我正在使用angular cli。这就是我最初安装它的方式。我再次运行该命令只是为了确定,google vision依赖于package.json中的依赖项,但我仍然得到相同的错误。我认为问题在于谷歌视觉本身的依赖性,而不是项目的依赖性。我可能完全错了,因为我是npm的新手,所以我对npm不是很熟悉。