There has been a lot of discussion on this error in the following issue:
Generate js file from proto file with protoc v21.1 #127
If any of you are open to using a different package for generating static code then you can use the following.
protobufjs-cli
Command line interface (CLI) for protobuf.js.
This can be used to translate between file formats and to generate static code as well as TypeScript definitions.
Installation:
npm i protobufjs-cli
Usage:
$> pbjs -t static-module -w commonjs -o compiled.js file1.proto file2.proto
I started using this package after I got the protoc-gen-js
related error when using the protoc
compiler for windows. I didn't find any solution mentioned in the issue linked above (as of June 2024) appealing, and I didn't want to install protoc-gen-js
globally.
protoc
. Are you running a recent version ofprotoc
? What doesprotoc --version
yield? See releases.protoc
does match e.g.--go_out
toprotoc-gen-go
for external plugins but, it should not need to do this for JavaScript. – Hypochondriaclibprotoc 3.21.1
– Rembrandtprotoc
3.19.4 and that includesprotoc-gen-js
. You could revert to that, or chop through versions to find where it 'broke" (perhaps try 21.0?) – Hypochondriaclibprotoc 3.17.1
and it caused the same issue – Rembrandt