-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting error "protoc-gen-js: program not found or is not executable" when trying to compile #105
Comments
please roll back version to older ( 3.15 work for me) |
Rolling back to 3.15 worked for me. I chose 3.15.8, the latest version I could find of the 3.15.x version. When I compile using those two compile commands above, they both work. They have different results, which are the results I expected after reading the README in this repo. The first command produces code with Since it's apparently possible to compile Protobuf messages to JavaScript with only |
This issue hit me, too. I'm wondering whether Rolling back to 3.15.8 solved the issue for me as well, but staying stuck on an older version of protoc is obviously not ideal. |
https://github.com/protocolbuffers/protobuf |
See protocolbuffers/protobuf#9874 Seems like it should have been better documented |
@ccakes I actually found that issue before I ran into this problem. I decided to follow the GitHub repos, leading me to this repo, where the documentation provides instructions for how to use Protobuf with JavaScript. I created this issue because when I followed those instructions, it didn't work. |
I use the version that is 3.20.1 works, google-protobuf and protobuf-javascript are the same version. |
Duplicate of #127 |
I have created a npm package to help everyone. You can now You can also Right now the only version supported is '3.21.2' but I'll try to keep it up to date as new releases are made. |
Install |
i have same issue for reactjs |
I think you need to add protoc-gen-js to your PATH or use --plugin to specify its location. |
I'm trying to use protoc to compile my Protobuf types into JavaScript. I already set up protoc on my computer by downloading it from the GitHub releases page, moving the protoc binary onto my path, and moving the includes directory into the directory on my computer recommended in its readme file.
I have the file
protos/message.proto
in my project:And I have the following script to compile it:
#!/bin/env bash protoc -I=. --js_out=. protos/message.proto
When I run that script, I get an error:
In the readme file for this project, I see that it recommends compiling a different way, with different options than just all defaults, so I also tried this as my compile script:
#!/bin/env bash protoc -I=. --js_out=import_style=commonjs,binary:. protos/message.proto
It made no difference. I got the same error.
I do have some experience with Protobuf, using it with Java and Go. For Java, I used the official Gradle plugin where you don't need to download the protoc binary or the include files, you just configure your Gradle config files and Gradle fetches the compiler and invokes it. For Go, I remember having to install a Go specific plugin. The Go plugin is well-documented in https://github.com/golang/protobuf. That makes me think the error I'm getting trying to compile to JavaScript is telling me that there is a JavaScript equivalent of that Go plugin, which I'd need to have on my system in order to compile to JavaScript.
But I can't find any documentation this plugin. I don't see anything on NPM that I can download (nothing called "protoc-gen-js" etc), nothing on the old GitHub repo for all languages (https://github.com/protocolbuffers/protobuf), and nothing on this new JavaScript-specific Protobuf repo. I tried installing the NPM package "google-protobuf" into my project, and then running the script, but I still get the error. I also tried installing that NPM package globally, thinking that perhaps there's a system binary that would be installed that I could use, but that didn't work either. Same error.
I found issue protocolbuffers/protobuf#4840 when googling my error. It talks about JS support being added in 3.0. So it might help to note that I'm using the latest version I downloaded today:
I expected that compiling to JS would work because I'm using 3+.
The text was updated successfully, but these errors were encountered: