protocolbuffers / protobuf-javascript

BSD 3-Clause "New" or "Revised" License
330 stars 66 forks source link

Failure using "buf generate" #203

Closed adokhugi closed 2 months ago

adokhugi commented 2 months ago

I was following the tutorial at https://dev.to/devaddict/use-grpc-with-node-js-and-typescript-3c58. When I typed "buf generate" I got the error message "Failure: plugin js: js moved to a separate plugin hosted at https://github.com/protocolbuffers/protobuf-javascript in v21, you must install this plugin". So I entered "git clone https://github.com/protocolbuffers/protobuf-javascript --recurse-submodules" in the same directory, followed by "npm install". Now when I execute "buf generate" again, I get tons of error messages about symbols being already defined, e.g.:

protobuf-javascript\compatibility_tests\v3.0.0\commonjs\test6\test6.proto:38:9:symbol "jspb.test.importing.ImportedMessage" already defined at protobuf-javascript/commonjs/test6/test6.proto:38:9 protobuf-javascript\compatibility_tests\v3.0.0\commonjs\test6\test6.proto:39:10:symbol "jspb.test.importing.ImportedMessage.string_value" already defined at protobuf-javascript/commonjs/test6/test6.proto:39:10 protobuf-javascript\compatibility_tests\v3.0.0\data.proto:41:9:symbol "jspb.test.data" already defined at protobuf-javascript/protos/data.proto:41:9 protobuf-javascript\compatibility_tests\v3.0.0\data.proto:42:11:symbol "jspb.test.data.NestedData" already defined at protobuf-javascript/protos/data.proto:42:11 protobuf-javascript\compatibility_tests\v3.0.0\data.proto:43:21:symbol "jspb.test.data.NestedData.str" already defined at protobuf-javascript/protos/data.proto:43:21 protobuf-javascript\compatibility_tests\v3.0.0\data.proto:48:9:symbol "jspb.test.UnnestedData" already defined at protobuf-javascript/protos/data.proto:48:9 protobuf-javascript\compatibility_tests\v3.0.0\data.proto:49:19:symbol "jspb.test.UnnestedData.str" already defined at protobuf-javascript/protos/data.proto:49:19 protobuf-javascript\compatibility_tests\v3.0.0\test2.proto:38:9:symbol "jspb.test.TestExtensionsMessage" already defined at protobuf-javascript/compatibility_tests/v3.1.0/test2.proto:38:9

What am I doing wrong?

adokhugi commented 2 months ago

I found the remark "If you having issues (like below) running the buf generate command" at the bottom of the aforelinked page. With the workaround described there I managed to obtain the pb.ts file.

dibenede commented 2 months ago

Hi,

I'm not particularly familiar with buf -- it's a tool/library offered by another company, so you may have more luck asking on their project (https://github.com/bufbuild/buf).

The tutorial is correct so far as this is the authoritative repo for protobuf-javascript itself. I'm not sure how buf uses our tooling.

If you do need to install protobuf-javascript separately, I would recommend installing from your choice of packaging system. On npm, we are https://www.npmjs.com/package/google-protobuf or one of the pre-built releases.