1

i need to use GRPC in nodejs an type script project , i have a problem with generate proto files in windows 10 and npm .

i want to ru this file transpile-proto-ts.sh:

#!/usr/bin/env bash

OUT_DIR="./src"
TS_OUT_DIR="./src"
IN_DIR="./protos"
PROTOC="$(npm bin)/grpc_tools_node_protoc"
PROTOC_GEN_TS_PATH="$(npm bin)/protoc-gen-ts"
PROTOC_GEN_GRPC_PATH="$(npm bin)/grpc_tools_node_protoc_plugin"

$PROTOC \
    -I="./" \
    --plugin=protoc-gen-ts=$PROTOC_GEN_TS_PATH \
    --plugin=protoc-gen-grpc=${PROTOC_GEN_GRPC_PATH} \
    --js_out=import_style=commonjs:$OUT_DIR \
    --grpc_out=grpc_js:$OUT_DIR \
    --ts_out=grpc_js:$TS_OUT_DIR \
    "$IN_DIR"/*.proto

but when i run this command in git bash : bash transpile-proto-ts.sh

it show me this error :

>--ts_out: protoc-gen-ts: %1 is not a valid Win32 application.

C:\Projects\GRPC\node_modules\grpc-tools\bin\protoc.js:41
    throw error;
    ^

Error: Command failed: C:\Projects\GRPC\node_modules\grpc-tools\bin\protoc.exe --plugin=protoc-gen-grpc=C:\Projects\GRPC\node_modules\grpc-tools\bin\grpc_node_plugin.exe --plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --js_out=import_style=commonjs,binary:./protos --ts_out=./protos --grpc_out=./protos -I ./protos ./protos/example.proto
--ts_out: protoc-gen-ts: %1 is not a valid Win32 application.


    at ChildProcess.exithandler (node:child_process:397:12)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'C:\\Projects\\GRPC\\node_modules\\grpc-tools\\bin\\protoc.exe --plugin=protoc-gen-grpc=C:\\Projects\\GRPC\\node_modules\\grpc-tools\\bin\\grpc_node_plugin.exe --plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --js_out=import_style=commonjs,binary:./protos --ts_out=./protos --grpc_out=./protos -I ./protos ./protos/example.proto'
}
1
  • How did you install the protoc-gen-ts plugin ? Commented Mar 24, 2022 at 9:28

1 Answer 1

1

Make sure that your sh file is executable as

chmod 777 transpile-proto-ts.sh

I had a similar issue and I used YARN instead of NPM.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.