Protoc does not export grpc-web files [MacOS]

180 views
Skip to first unread message

Antonello Palazzi

unread,
May 16, 2022, 4:36:58 PM5/16/22
to grpc.io

I have a simple proto file:

syntax = "proto3";

package SettingsSvc;
service Settings {
  rpc FetchSettings(SettingsRequest) returns (SettingsResponse) {}
}

message SettingsRequest { 
  string language = 1;
}

message SettingsResponse {
  string cvTooltip = 1;
  string themeTooltip = 2;
  string githubLocation = 3;
  string gitlabLocation = 4;
  string linkedinLocation = 5;
  string name = 6;
  int32 year = 7;
}

I am trying to generate the files for a react (TS template) web client. As suggested by the official grpc-web page I am running the protoc command as follows:

protoc -I=. settings.proto --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=typescript,mode=grpcweb:.

However, the only file I get is "settings_pb.js", which is the one generated by the "--js_out" instruction. The file that should be generated by the "--grpc-web_out" instruction (SettingsClientPb.ts) is missing.

I tried using "import_style=commonjs" and "import_style=commonjs+dts" as well, but no luck. The command returns no errors but it does not produce the expected output files.

I installed protoc with brew and I am using version 1.3.1 of the grpc-web code generator plugin.

Can someone help?

Thanks.

Antonello

Eryu Xia

unread,
May 25, 2022, 7:48:19 PM5/25/22
to grpc.io
Hi! Thanks for the question!

I've tried the same commands and was able to get the grpc-web ts files:
Screen Shot 2022-05-25 at 4.43.28 PM.png


I wonder if by any chance your protoc-gen-grpc-web is not installed or working properly (installation guide here)?

Curious what's the output for the following commands for you (and attaching my results):
Screen Shot 2022-05-25 at 4.46.12 PM.png

Thanks!

(btw do you mind posting your question (as an Issue) on https://github.com/grpc/grpc-web next time for easier triage? thanks!)

Reply all
Reply to author
Forward
0 new messages