1. 安装 protoc and protoc-gen-grpc-web 插件
protoc 下载: https://github.com/protocolbuffers/protobuf/releases
protoc-gen-grpc-web 插件下载: https://github.com/grpc/grpc-web/releases
2. 将 protoc and protoc-gen-grpc-web 安装目录的 Bin 添加到系统环境变量
3. 打开 CMD 切换目录到 gRPC 的 xxx.proto 下
运行如下命令,生成对应的 xxx_grpc_web_pb.js 和 xxx_pb.js 文件:
protoc -I=. xxx.proto --js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:.
浙公网安备 33010602011771号