无法使原型路径相对:src / app / protos / greet.proto:没有此类文件或目录

问题描述

enter image description here

我正在尝试根据以下文章创建gRPC Angular客户端:https://anthonygiretti.com/2020/03/29/grpc-asp-net-core-3-1-how-to-create-a-grpc-web-client-examples-with-angular-8-and-httpclient/

运行命令时

protoc --plugin=protoc-gen-ts="{ABSOLUTEPATH}\node_modules\.bin\protoc-gen-ts.cmd" 
       --js_out="import_style=commonjs,binary:src/app/generated" 
       --ts_out="service=grpc-web:src/app/generated" src/app/protos/greet.proto,

我收到一个错误Could not make proto path relative: src/app/protos/greet.proto: No such file or directory。目录和greet.proto文件确实存在。

我请求此问题的帮助。预先谢谢你!

解决方法

对于那些可能遇到此问题的人,文章的作者给出了答案。

  1. 该命令应在项目的根文件夹中运行。
  2. 此编辑后的命令有效:
protoc --plugin=protoc-gen-ts="C:/University/IT/Angular_grpc/angular-client/node_modules/ts-protoc-gen/bin/protoc-gen-ts.cmd" --js_out="import_style=commonjs,binary:src/app/generated" --ts_out="service=grpc-web:src/app/generated" src/app/protos/greet.proto