i_Am_Groot
i_Am_Groot

Reputation: 51

Installation of protoc-gen-grpc-web

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!

Upvotes: 5

Views: 13558

Answers (4)

NotX
NotX

Reputation: 2395

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

That said, maybe it makes more sense to add ./node_modules/.bin to your path in general.

Upvotes: 3

Vikash Gupta
Vikash Gupta

Reputation: 31

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

Upvotes: 1

Shan
Shan

Reputation: 31

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

$ brew install protoc-gen-grpc-web

Upvotes: 3

j4ckofalltrades
j4ckofalltrades

Reputation: 610

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

Upvotes: 4

Related Questions