grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.45k stars 760 forks source link

Compile & run helloworld: protoc-gen-js: Plugin failed with status code 126 #1395

Closed plvaldes closed 5 months ago

plvaldes commented 5 months ago

Hi all

I'm struggling to make the helloworld example work. This is what I have:

Then I tried to generate the javascript files for the proto file:

protoc -I=. helloworld.proto \
  --js_out=import_style=commonjs:. \
  --grpc-web_out=import_style=commonjs,mode=grpcwebtext:.

I got this error:

protoc-gen-js: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--js_out: protoc-gen-js: Plugin failed with status code 1.

From this point I started reviewing a few docs to see what it is missing. In the root dir of this repo (grpc-web) I found similar instructions to the ones in the helloworld example but I saw a comment about protoc not supporting javascript output anymore. So from the error above I guess I need to install protoc-gen-js, which seems to be part of protobuf-javascript.

So I did something similar for protobuf-javascript. I downloaded a release, moved it to /usr/local/bin and made sure the file in bin is executable. But when I try to compile with protoc I find a different error:

/usr/local/bin/protobuf-javascript/bin/protoc-gen-js: /usr/local/bin/protobuf-javascript/bin/protoc-gen-js: cannot execute binary file
--js_out: protoc-gen-js: Plugin failed with status code 126.

I've created an issue on the protobuf-javascript repo to get help on this, but I'd like to know if I need protoc-gen-js at all (the instructions on the helloworld example readme don't mention it) or I am doing something wrong before getting to that issue.

I'm running this on MacOS 14.2.

Thank you very much for your help 🙏🏼

plvaldes commented 5 months ago

Closing ticket, solved in https://github.com/protocolbuffers/protobuf-javascript/issues/183