在 grpc 节点中生成协议缓冲区时出错

问题描述 投票:0回答:1

我想在 Nodejs 中使用 gRPC 构建微服务,但出现错误。

我安装了

[email protected]
[email protected]
,但是当我输入这个命令时:

grpc_tools_node_protoc --js_out=import_style=commonjs,binary:./generated --grpc_out=./generated --proto_path=./protos ./protos/*.proto

我收到此错误:

\AppData\Roaming\npm\node_modules\grpc-tools\bin\protoc.js:41
    throw error;
    ^

Error: Command failed: \AppData\Roaming\npm\node_modules\grpc-tools\bin\protoc.exe --plugin=protoc-gen-grpc=\AppData\Roaming\npm\node_modules\grpc-tools\bin\grpc_node_plugin.exe --js_out=import_style=commonjs,binary:./generated --grpc_out=./generated --proto_path=./protos ./protos/*.proto

←[90m    at ChildProcess.exithandler (child_process.js:303:12)←[39m
←[90m    at ChildProcess.emit (events.js:315:20)←[39m
←[90m    at maybeClose (internal/child_process.js:1026:16)←[39m
←[90m    at Socket.<anonymous> (internal/child_process.js:441:11)←[39m
←[90m    at Socket.emit (events.js:315:20)←[39m
←[90m    at Pipe.<anonymous> (net.js:674:12)←[39m {
  killed: ←[33mfalse←[39m,
  code: ←[33m3221225781←[39m,
  signal: ←[1mnull←[22m,
  cmd: ←[32m'\\AppData\\Roaming\\npm\\node_modules\\grpc-tools\\bin\\protoc.exe --plugin=protoc-gen-grpc=\\AppData\\Roaming\\npm\\node_modules\\grpc-tools\\bin\\grpc_node_plugin.exe --js_out=import_style=commonjs,binary:./generated --grpc_out=./generated --proto_path=./protos ./protos/*.proto'←[39m
}

这让我发疯:(

node.js grpc protoc grpc-node
1个回答
0
投票

我不知道确切的原因和问题,但将 @grpc/grpc-js 降级到 1.6.6grpc-tools1.11.2 对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.