What am I doing wrong while trying to create a GRPC for web from my proto definition using protoc command in JavaScript?

huangapple go评论49阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年5月29日 22:21:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76358126.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定