Have a relatively simple helloworld.proto
file down below
syntax = "proto3";
package helloworld;
service Greeter { rpc SayHello(HelloRequest) returns (HelloResponse); }
message HelloRequest { string name = 1; }
message HelloResponse { string message = 1; }
When I run protoc --js_out=import_style=commonjs,binary:. .\helloworld.proto
it generates a helloworld_pb.js
file but it doesn't include my Greeter
service nor my SayHello
rpc function. Looked around a few other post and also Google's reference (https://developers.google.com/protocol-buffers/docs/reference/overview) and it seems like I need to include a --plugin
option but I can't seem to find any. Does anybody have a solution to for this?
The protoc
plugin for Node gRPC is distributed in the grpc-tools
npm package. That package provides a tool grpc_tools_node_protoc
that is a version of protoc
that automatically includes the plugin.
As described in that package's README, when you run the tool you will also need to use the --grpc_out
argument to control the plugin. The question is tagged grpc-js
, so you will probably want to use the grpc_js
option for that argument to generate code that interacts with grpc-js
.