我正在使用带有角度的 grpc。 我的 package.json:
{
"name": "angular13",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.0.0-next.0",
"@angular/common": "~13.0.0-next.0",
"@angular/compiler": "~13.0.0-next.0",
"@angular/core": "~13.0.0-next.0",
"@angular/forms": "~13.0.0-next.0",
"@angular/material": "^13.0.0",
"@angular/platform-browser": "~13.0.0-next.0",
"@angular/platform-browser-dynamic": "~13.0.0-next.0",
"@angular/router": "~13.0.0-next.0",
"@auth0/angular-jwt": "^5.0.2",
"@improbable-eng/grpc-web": "^0.15.0",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"@popperjs/core": "^2.10.1",
"@protobuf-ts/grpcweb-transport": "^2.0.6",
"@protobuf-ts/runtime": "^2.0.6",
"bootstrap": "^5.1.2",
"bootstrap-icons": "^1.7.0",
"google-protobuf": "^3.21.2",
"grpc-web": "^1.4.2",
"material-icons": "^1.3.0",
"rxjs": "~7.4.0",
"simple-keyboard": "^3.5.40",
"simple-keyboard-layouts": "^3.1.297",
"ts-protoc-gen": "^0.15.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^13.3.10",
"@angular/cli": "~13.0.0",
"@angular/compiler-cli": "~13.0.0-next.0",
"@protobuf-ts/plugin": "^2.9.0",
"@types/google-protobuf": "^3.15.6",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.10.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.4.3"
}
}
我正在运行以下命令来生成原型文件
protoc --plugin=protoc-gen-ts="C:\Users\...\source\...\node_modules\.bin\protoc-gen-ts.cmd" --js_out="import_style=commonjs,binary:C:\Users\...\source\...\src\app\api\protos\generated" --ts_out="service=grpc-web:C:\Users\...\source\...\src\app\api\protos\generated" plc.proto
出现此错误:
Option "service=grpc-web" not recognized.
我重新安装了相关的 npms ts-protoc-gen、google-protobuf、@types/google-protobuf 和 @improbable-eng/grpc-web,但仍然无法正常工作。 谢谢!