使用ProtoC V21.1从原始文件中生成JS文件

发布于 2025-02-05 04:29:23 字数 412 浏览 2 评论 0原文

命令使用 -

protoc.exe --js_out=import_style=commonjs,binary:. employees.proto

错误 -

'protoc-gen-js' is not recognized as an internal or external command,
operable program or batch file.

使用的版本 -

protoc.exe --version                              
libprotoc 3.21.1

--js_out: protoc-gen-js: Plugin failed with status code 1.

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.

Version Used -

protoc.exe --version                              
libprotoc 3.21.1

--js_out: protoc-gen-js: Plugin failed with status code 1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黒涩兲箜 2025-02-12 04:29:23

您可以在以下问题下找到有关此错误的更多详细信息:

从proto noreferrer“ Protoc V21.1#127

如果您有兴趣使用其他包装来生成静态代码,则可以使用以下内容。

protobufjs-cli

命令行界面(CLI)用于 protobuf.js

这可用于在文件格式之间转换和生成静态代码以及打字稿定义。

安装:

npm i protobufjs-cli

用法:

gt; pbjs -t static-module -w commonjs -o compiled.js file1.proto file2.proto

在收到您遇到的错误后,我开始使用此软件包。我没有发现该问题(截至2024年6月)中提到的任何解决方案吸引人。

You can find more details on this error under the following issue:

Generate js file from proto file with protoc v21.1 #127

If you are interested in 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:

gt; pbjs -t static-module -w commonjs -o compiled.js file1.proto file2.proto

I started using this package after I got the error you got. I didn't find any of the solutions mentioned in the issue (as of June 2024) appealing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文