英文:
What am I doing wrong while trying to create a GRPC for web from my proto definition using protoc command in JavaScript?
问题
I'm trying to create a JavaScript from my proto definition.
我正在尝试从我的 proto 定义中创建 JavaScript。
I'm using this command:
我正在使用以下命令:
protoc \
--proto_path=./grpc \
--grpc-web_out=mode=grpcwebtext:./lib/gerado/grpc/js/ \
--fatal_warnings interface.proto
But nothing is generated. And no one message of error is show.
What I'm doing wrong?
但是没有生成任何内容。也没有显示任何错误消息。我做错了什么?
I have been tried all kind of approach to solve this.
我已经尝试了各种方法来解决这个问题。
P.S.: Only now i notice that if in my .proto file there is at least one service, than no output is generated to javascript.
附注:只有现在我注意到,如果在我的 .proto 文件中至少有一个服务,那么就不会生成 JavaScript 输出。
英文:
I'm trying to create a JavaScript from my proto definition.
I'm using this command:
protoc \
--proto_path=./grpc \
--grpc-web_out=mode=grpcwebtext:./lib/gerado/grpc/js/ \
--fatal_warnings interface.proto
But nothing is generated. And no one message of error is show.
What I'm doing wrong?
I have been tried all kind of approach to solve this.
> P.S.: Only now i notice that if in my .proto file there is at least
> one service, than no output is generated to javascript.
答案1
得分: 2
interface.proto
:
syntax = "proto3";
service X {
rpc Y(Z) returns (Z);
}
message Z {
};
With binaries from the releases added to {PATH}
:
And without --js_out
:
protoc \
--proto_path=${PWD} \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:${PWD} \
${PWD}/interface.proto
Generates interface_grpc_web_pb.js
as expected.
With --js_out
:
protoc \
--proto_path=${PWD} \
--js_out=import_style=commonjs:${PWD} \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:${PWD} \
${PWD}/interface.proto
Additionally generates interface_pb.js
英文:
interface.proto
:
syntax = "proto3";
service X {
rpc Y(Z) returns (Z);
}
message Z {
};
With binaries from the releases added to {PATH}
:
And without --js_out
:
protoc \
--proto_path=${PWD} \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:${PWD} \
${PWD}/interface.proto
Generates interface_grpc_web_pb.js
as expected.
With --js_out
:
protoc \
--proto_path=${PWD} \
--js_out=import_style=commonjs:${PWD} \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:${PWD} \
${PWD}/interface.proto
Additionally generates interface_pb.js
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论