23

Trying to compile my protos - I need to compile them to use in my react app. But I get this error. I run the command as follows:

cd src/main/proto && protoc -I=. *.proto --js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:.

Where can I find protoc-gen-js? I didn't come across any repo for it.

8
  • I think that JavaScript code generation is now built-in to protoc. Are you running a recent version of protoc? What does protoc --version yield? See releases. protoc does match e.g. --go_out to protoc-gen-go for external plugins but, it should not need to do this for JavaScript.
    – DazWilkin
    Jun 11, 2022 at 3:19
  • @DazWilkin yes, its a recent version, I have this installed libprotoc 3.21.1 Jun 13, 2022 at 13:49
  • @DazWilkin do you know a workaround for this? Jun 13, 2022 at 13:50
  • 1
    Interesting..... See: Issue #10114
    – DazWilkin
    Jun 13, 2022 at 15:41
  • I have protoc 3.19.4 and that includes protoc-gen-js. You could revert to that, or chop through versions to find where it 'broke" (perhaps try 21.0?)
    – DazWilkin
    Jun 13, 2022 at 15:43

5 Answers 5

30

As of July 2022, there is a known bug in protoc versions 21.1 and 21.2 (and libprotoc 3.21.1 and libprotoc 3.21.2).

See protobuf issue #10114.

For now, recommend downgrading to version 20.1 (libprotoc 3.20.1).

3
  • 1
    indeed, I had the same issue, downgrading solved it Jul 14, 2022 at 14:43
  • How do I downgrade?
    – David G
    Mar 9, 2023 at 17:47
  • 1
    Thanks for the link! One year later the issue still isn't fixed though. But for now, it looks that like somebody made the plugin available, so you can install it manually as described in the comments there, which might be a better solution than downgrading.
    – NotX
    Apr 19, 2023 at 8:05
17

run this command this command will globally install protoc-gen-js

  npm install -g protoc-gen-js
13

For Mac users using brew and the provided link by Christopher Peisert what worked for me was the suggested workaround:

$brew install protobuf@3

$brew link --overwrite protobuf@3
0
1

You should install this package globally or in the project devDependencies.

NPM

npm install -g protoc-gen-js
// or
npm install protoc-gen-js --save-dev

YARN

yarn global add protoc-gen-js
// or
yarn add protoc-gen-js --dev
0

Can downgrade to @3 versions Please refer https://github.com/grpc/grpc-web/issues/704#issuecomment-1215965557

1
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Jul 6, 2023 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.