4

I am currently working on using grpc-web to write a simple client for my service. I have created a service.proto file which was successfully compiled using protoc. The problem arose when I tried to generate the gRPC-Web service client stub using the plugin protoc-gen-grpc-web which doesnt work despite having installed the latter.

Got the following error :

protoc -I=./ service.proto --grpc-web_out=import_style=commonjs,mode=grpcwebtext:./
protoc-gen-grpc-web: program not found or is not executable
--grpc-web_out: protoc-gen-grpc-web: Plugin failed with status code 1.

Any suggestions on how to solve this issue? Thank you!

Gander
  • 1,854
  • 1
  • 23
  • 30
i_Am_Groot
  • 41
  • 1
  • 2

4 Answers4

4

You'll need to make the protoc-gen-grpc-web plugin executable and move it to a directory that is discoverable from your PATH environment variable.

From grpc-web/README:

For example, in MacOS, you can do:

$ sudo mv ~/Downloads/protoc-gen-grpc-web-1.2.1-darwin-x86_64 \  
/usr/local/bin/protoc-gen-grpc-web
$ chmod +x /usr/local/bin/protoc-gen-grpc-web
j4ckofalltrades
  • 572
  • 1
  • 5
  • 16
2

You don't even have to install the plugin globally and make it discoverable from your PATH:

protoc accepts --plugin arguments to point to a required plugin. For protoc-gen-grpc-web (as for many others) there's even npm support, so you can get it with npm i --save-dev protoc-gen-grpc-web and then run protoc with --plugin=protoc-gen-grpc-web=./node_modules/.bin/protoc-gen-grpc-web

NotX
  • 1,516
  • 1
  • 14
  • 28
2

I'm using MacOS. You need to install this first with brew

$ brew install protoc-gen-grpc-web
Shan
  • 21
  • 2
1

The best solution that I could use for Linux based system was globally installing protoc-gen-grpc-web. This directly takes the files from the /bin of the node_modules files created globally across your system

sudo npm install -g protoc-gen-grpc-web