Closed YPhyu closed 7 years ago
@YPhyu add .cmd
to the end of it and it works (using this locally on a Win10 computer)
Thanks. It works fine now.
running on windows 7 still not successful: npm install ts-protoc-gen within the project directory creates a new package directory, but there's no ts-protoc-gen.cmd file in the bin directory, only ts-protoc-gen (a javascript file without the extension)
Is the installation on windows supposed to create a separate launcher?
@bonnyr the plugin (protoc-gen-ts.cmd not ts-protoc-gen.cmd) is under node_modules\.bin
here's my copy of the bin directory (inside the current project):
λ dir ......\node_modules\ts-protoc-gen\bin Volume in drive E is New Volume Volume Serial Number is 306C-DC6D
Directory of
10/06/2017 01:07 AM
Am I missing something here?
You should look for the plugin at node_modules\.bin rather than Directory of
My bad - thanks for this. It's working now
Hi, I am trying to run ts-protoc-gen from PowerShell. I type the following command
$protoc = 'C:\Users\admin\.nuget\packages\google.protobuf.tools\3.5.0\tools\windows_x64\protoc.exe'
$arguments = "--plugin=protoc-gen-ts=.\node_modules\.bin\protoc-gen-ts.cmd --js_out=import_style=commonjs,binary:generated --ts_out=service=true:generated -I .\proto .\proto\Person.proto"
Start-Process $protoc -ArgumentList $arguments -NoNewWindow
And receive the following error generated/: No such file or directory. I thought that it is probably slash direction problem, cause on windows it's considered to use \. However powershell don't mind in which direction is used space, but probably plugin internally can't resolve paths. I have changed the direction of splash and there is error:
'.' is not recognized as an internal or external command, operable program or batch file. --ts_out: protoc-gen-ts: Plugin failed with status code 1.
Does anyone tried to execute command from powershell. Maybe I'm doing something wrong?
@unsafePtr
Looks like windows can't use relative path with .\
Try:
--plugin=protoc-gen-ts=%CD%/node_modules/.bin/protoc-gen-ts.cmd
or absolute path:
--plugin=protoc-gen-ts=C:/path/to/project/node_modules/.bin/protoc-gen-ts.cmd
PROJECT_BIN="./node_modules/.bin" PROTOC=".\protoc.exe" PROTO_DIR="proto" GRPC_OUT=".\src\grpc"
PROTOC_GEN_TS_PATH=".\node_modules\.bin\protoc-gen-ts.cmd"
$PROTOC -I=$PROTO_DIR wechat.proto \ --plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \ --js_out=import_style=commonjs,binary:$GRPC_OUT \ --ts_out=:$GRPC_OUT \
I used D:\Projects\Test\helloworld\node_modules.bin\protoc-gen-ts.cmd $ .\build.sh Missing output directives. .\build.sh: line 20: --plugin=protoc-gen-ts=D:\Projects\Test\helloworld\node_modules.bin\protoc-gen-ts.cmd: No such file or directory
I used .\node_modules.bin\protoc-gen-ts.cmd Tao@Tao MINGW64 /d/Projects/Test/helloworld $ .\build.sh Missing output directives. .\build.sh: line 20: --plugin=protoc-gen-ts=.\node_modules.bin\protoc-gen-ts.cmd: No such file or directory
I am so so... build it for one night~~~~
PROTOC_GEN_TS_PATH="%CD%/node_modules/.bin/protoc-gen-ts.cmd"
Tao@Tao MINGW64 /d/Projects/Test/helloworld $ .\build.sh Missing output directives. .\build.sh: line 21: --plugin=protoc-gen-ts=%CD%/node_modules/.bin/protoc-gen-ts.cmd: No such file or directory
PROTOC_GEN_TS_PATH="%CD%\node_modules\ts-protoc-gen\bin\protoc-gen-ts.cmd" Tao@Tao MINGW64 /d/Projects/Test/helloworld $ .\build.sh Missing output directives. .\build.sh: line 21: --plugin=protoc-gen-ts=%CD%\node_modules\ts-protoc-gen\bin\protoc-gen-ts.cmd: No such file or directory
Tao@Tao MINGW64 /d/Projects/Test/helloworld $ .\build.sh Missing output directives. .\build.sh: line 21: --plugin=protoc-gen-ts=%CD%/node_modules/ts-protoc-gen/bin/protoc-gen-ts.cmd: No such file or directory
I was falling apart. I wasn't getting any sleep.
PROTOC=".\\protoc.exe"
PROTO_DIR="proto"
GRPC_OUT=".\\src\\grpc"
$PROTOC -I=$PROTO_DIR wechat.proto \
--js_out=import_style=commonjs:$GRPC_OUT \
--grpc-web_out=import_style=typescript,mode=grpcweb:$GRPC_OUT
Tao@Tao MINGW64 /d/Projects/Test/helloworld $ .\build.sh
Tao@Tao MINGW64 /d/Projects/Test/helloworld $
3 files were created by build.sh \helloworld\src\grpc\wechat_pb.d.ts \helloworld\src\grpc\wechat_pb.js \helloworld\src\grpc\WechatServiceClientPb.ts If I used grpc-web, It work well
But I modified it for @improbable-eng/grpc-web and protoc-gen-ts, It can't work I was very angry with myself for making such a stupid mistake.
# generates TypeScript declarations (.d.ts files)
# output service definitions as both .js and .d.ts files in the structure required by grpc-web
# output service definitions as both .js and .d.ts files in the structure required by grpc-node
# .//build.sh
PROJECT_BIN="./node_modules/.bin"
# protoc路径
PROTOC=".\\protoc.exe"
# *.proto文件的存放路径
PROTO_DIR="proto"
# Directory to write generated code to (.js and .d.ts files)
GRPC_OUT=".\\src\\grpc"
# Generating TypeScript Definitions for CommonJS modules generated by protoc
# Path to ts-protoc-gen
PROTOC_GEN_TS=".\\node_modules\\.bin\\protoc-gen-ts.cmd"
# Generating gRPC Service Stubs for use with grpc-web
$PROTOC \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS}" \
--js_out="import_style=commonjs,binary:${GRPC_OUT}" \
--ts_out="service=grpc-web:${GRPC_OUT}" \
-I=$PROTO_DIR wechat.proto
# generates TypeScript declarations (.d.ts files)
# output service definitions as both .js and .d.ts files in the structure required by grpc-web
# output service definitions as both .js and .d.ts files in the structure required by grpc-node
# .//build.sh
PROJECT_BIN="./node_modules/.bin"
# protoc路径
PROTOC=".\\protoc.exe"
# *.proto文件的存放路径
PROTO_DIR="proto"
# Directory to write generated code to (.js and .d.ts files)
GRPC_OUT=".\\src\\grpc"
# Generating TypeScript Definitions for CommonJS modules generated by protoc
# Path to ts-protoc-gen
PROTOC_GEN_TS=".\\node_modules\\.bin\\protoc-gen-ts.cmd"
# Generating gRPC Service Stubs for use with grpc-node
$PROTOC \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS}" \
--js_out="import_style=commonjs,binary:${GRPC_OUT}" \
--ts_out="service=grpc-node,mode=grpc-js:${GRPC_OUT}" \
-I=$PROTO_DIR wechat.proto
I'm working in nest js on the microservices architecture (grpc) and want to generate ts file from my proto file but when I run the following command on cmd:
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./ --ts_proto_opt=nestJs=true ./proto/users.proto
I get the following error:
--ts_proto_out: protoc-gen-ts_proto: %1 is not a valid Win32 application.
Kindly help me out.
I'm working in nest js on the microservices architecture (grpc) and want to generate ts file from my proto file but when I run the following command on cmd:
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./ --ts_proto_opt=nestJs=true ./proto/users.proto
I get the following error:
--ts_proto_out: protoc-gen-ts_proto: %1 is not a valid Win32 application.
Kindly help me out.
I think you need to run the command as:
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto.cmd --ts_proto_out=./ --ts_proto_opt=nestJs=true ./proto/users.proto
Or you could create a shortcut to ./node_modules/.bin/protoc-gen-ts_proto.cmd
from ./node_modules/.bin/protoc-gen-ts_proto
on windows machines if youre working with other devs in other environments
I'm working in nest js on the microservices architecture (grpc) and want to generate ts file from my proto file but when I run the following command on cmd:
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./ --ts_proto_opt=nestJs=true ./proto/users.proto
I get the following error:--ts_proto_out: protoc-gen-ts_proto: %1 is not a valid Win32 application.
Kindly help me out.I think you need to run the command as:
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto.cmd --ts_proto_out=./ --ts_proto_opt=nestJs=true ./proto/users.proto
Or you could create a shortcut to
./node_modules/.bin/protoc-gen-ts_proto.cmd
from./node_modules/.bin/protoc-gen-ts_proto
on windows machines if youre working with other devs in other environments
Getting this -
'protoc-gen-ts_proto' is not recognized as an internal or external command, operable program or batch file. --ts_proto_out: protoc-gen-ts_proto: Plugin failed with status code 1.
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto.cmd --ts_proto_out=./ --ts_proto_opt=nestJs=true ./proto/
try to run it like this:
protoc --plugin=protoc-gen-ts_proto="$(npm root)\.bin\protoc-gen-
ts_proto.cmd" --ts_proto_out=./ --ts_proto_opt=nestJs=true ./proto/yourfile.proto
I am trying out grpc-web and grpc-proxy. I am getting error when I try to compile proto to ts.
Error: ts_out: protoc-gen-ts: 1% is not a valid Win32 application.
Thank you for your help in advance.