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
Generate js file from proto file with protoc v21.1 #127
Comments
I encountered the same issue upgrading to version 3.21.1 from 3.20.0 |
I'm having a same issue. Is there any solution yet? |
Really looking forward to this fix. |
I'm having the same issue on macOS:
I don't see I've seen that the release notes for v21.0-rc1 link to a document explaining that javascript has been moved out of the main repository to allow it to evolve independently of Note that the v20.1 release provides an additional js asset that I also wasn't able to make use of. Couldn't find any useful instructions. I downgraded to v20.1 and then I don't get this problem. PS: I'm new to installing protobuf from the official releases; I've used |
I also encountered the same issue when I use the v3.21.0. which verson can I use ? I want to generate js File |
I have the same on 3.21.2 |
@haberman 21.x breaks JS and there's no known workaround for OSX / brew no release notes on removing JSno way to downgrade
no releases on the js splithttps://github.com/protocolbuffers/protobuf-javascript no build instructions on the js splithttps://github.com/protocolbuffers/protobuf-javascript the latest known working js release has no build instructions either |
workaround on OSX / brew:
Related |
Installed The suggestion by @clehene worked like a charm |
protobuf 21.4 Win x64 Compiler:
|
My findings. Clone protobu-javascript source code
Pass the path to the plugin option in protoc
Someday there might be a formal migration guide from the protocolbuffers team. |
Thanks for that, @johejo. I'm trying to figure out how in the world to get this working in a Bazel context, in which we use a third party JS gRPC proto generator (rules-proto-grpc), and that thing calls into protoc, expecting protoc to know what to do to generate JS protos. Ugh.. |
Google went and broke JS support in v3.21. See: protocolbuffers/protobuf-javascript#127
We are currently working on releasing binaries for protoc-gen-js, but it should be possible to build. You can find some better examples of the plugin invocation here: https://github.com/protocolbuffers/protobuf-javascript/blob/main/docs/index.md |
I was working trying to create protoc compilations for any version and multiple language now, I can replicated the error in a isolated container check https://github.com/pablodz/protoc-generator/tree/feat/error-protoc-node run
I hope this will help to fix errors easily |
If you're forced to downgrade and are running into issues with |
This worked for me (after Create an executable file
And then when running protoc:
|
Okay never mind, that didn't work at all. |
v3.22.0 still does not work:
|
This worked for us, thanks @johejo! It's definitely a headache compared to how it used to "just work" though. |
I have created a npm package to help everyone. You can now npm i protoc-gen-js inside a package.json directory to make the '--js_out' work in "scripts" in the package.json (i.e. if one of your package.json scripts calls 'protoc --js_out') and will allow you to specify the version of protoc-gen-js in your package.json You can also npm i -g protoc-gen-js or npm i -g protoc-gen-js@{version} and that will make '--js_out' work everywhere at the latest or specific version specified. 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. |
There is an official first-party solution: if you This way I managed to do without protoc-gen-js. |
@pietrodn I wouldn't consider that a solution. |
Thanks for the info, I wrongly assumed that at least the official |
I also build the You have to use |
Can you explain how you built protoc-gen-js? I'm trying to create a grpc client with Angular and javascript to use with my existing grpc server. I have .proto files but nothing is working to generate .js/.ts files. |
If you have an Angular/Javascript project, why does https://www.npmjs.com/package/protoc-gen-js from @yinzara not work for you? If you want to build it for yourself, it depends on which platform you are. For Linux/WSL2 or OSX, it is quite easy. Here the example for a linux x86_64 system (written as a Dockerfile): FROM debian:bullseye
# install prerequisites
# git: to download the repositoryy
# curl: to download/install bazel (the build system)
# build-essential: to build protoc-gen-js (C/C++ compiler)
RUN \
apt-get update && \
apt-get install -y git curl build-essential
# install bazel
RUN \
curl -sL https://github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-linux-x86_64 > /usr/local/bin/bazel && \
chmod +x /usr/local/bin/bazel
# build and install protoc-gen-js
RUN \
git clone https://github.com/protocolbuffers/protobuf-javascript.git && \
cd protobuf-javascript && \
bazel build //generator:protoc-gen-js && \
cp bazel-bin/generator/protoc-gen-js /usr/local/bin/protoc-gen-js
# protoc-gen-js is now installed in /usr/local/bin/protoc-gen-js For windows, it should also work (bazel and stuff is also available), but that is a whole different story. |
The "official first party solution" is to simply download the latest release from this repo and add it to your PATH. They should really update the README with these instructions and close this issue, as there is no real problem here. Not including the javascript runtime in the main protobuf installation was a conscious decision by the protobuf team, and now that there are proper pre-built binaries for this up for download, the only problem left is the lack of instructions really. |
@lily-es Thanks very much! That hint helped me a lot. |
@lily-es This was actually what I tried first. But it doesn't work: Using an alpine docker image I download the following releases from GitHub: ENV PROTOC_VERSION=24.0
ENV PROTO_GEN_JS_VERSION=3.21.2
ENV PROTO_GEN_JS_GRPC_VERSION=1.4.2
(All bin files are executable of course) And finally
/usr/local/bin/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. Something's still wrong. What's strange to me: executing |
Then you have to put in tooling to download the correct binary depending on OS. I'd rather just build from source and let bazel figure that out, that way we have one set of instructions common for all OS. |
My tooling is a simple bash script that checks btw in my case I did use the correct download, and it didn't work:
EditFound the solution: The binary doesn't support musl libc but glibc. ➡ Using a linux image with glibc (e.g. Debian image) solved the issue. The precompiled binaries work as expected. |
i'm having this problem. Using protoc version 24.0 and protoc-gen-grpc-web 1.4.2. |
@brunacat nothing else is needed.
|
I was using an Alpine (musl) based container, but switched to a Debian (glibc) based one. Thanks! Since musl is usually statically linked, the binary release would serve a wider audience if it used musl instead of glibc, which is usually dynamically linked. |
install protoc-gen-js via nami
|
You can now install brew install protoc-gen-js and then run "$(brew --prefix protobuf@21)/bin/protoc" --js_out=import_style=commonjs,binary:. employees.proto |
Command used -
protoc.exe --js_out=import_style=commonjs,binary:. employees.proto
Error -
'protoc-gen-js' is not recognized as an internal or external command,
operable program or batch file.
--js_out: protoc-gen-js: Plugin failed with status code 1.
The text was updated successfully, but these errors were encountered: