Comments (18)
@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
from ts-protoc-gen.
@YPhyu add .cmd
to the end of it and it works (using this locally on a Win10 computer)
from ts-protoc-gen.
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.
from ts-protoc-gen.
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
from ts-protoc-gen.
Thanks. It works fine now.
from ts-protoc-gen.
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?
from ts-protoc-gen.
@bonnyr the plugin (protoc-gen-ts.cmd not ts-protoc-gen.cmd) is under node_modules\.bin
from ts-protoc-gen.
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 <project_path>\node_modules\ts-protoc-gen\bin
10/06/2017 01:07 AM
.10/06/2017 01:07 AM ..
10/05/2017 03:04 PM 57 protoc-gen-js_service
10/05/2017 03:04 PM 49 protoc-gen-ts
2 File(s) 106 bytes
2 Dir(s) 45,089,464,320 bytes free
Am I missing something here?
from ts-protoc-gen.
You should look for the plugin at node_modules\.bin rather than Directory of <project_path>\node_modules\ts-protoc-gen\bin
from ts-protoc-gen.
My bad - thanks for this. It's working now
from ts-protoc-gen.
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?
from ts-protoc-gen.
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~~~~
from ts-protoc-gen.
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.
from ts-protoc-gen.
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.
from ts-protoc-gen.
# 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
the code above work well
from ts-protoc-gen.
# 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
#the code above work well
from ts-protoc-gen.
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.
from ts-protoc-gen.
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
from ts-protoc-gen.
Related Issues (20)
- d.ts files not generated HOT 4
- setXX() method return type is wrong in .d.ts file HOT 1
- proto3 - required / optional fields HOT 4
- Could we support friendlier object-literal syntax for service methods? HOT 1
- Fix TypeScript annotations for setters HOT 4
- Error: 13 INTERNAL: Request message serialization failure: Expected argument of type xxx HOT 3
- OnHeaders callback is not accessible. HOT 2
- How to deal with extensions? HOT 1
- Bad TS types for proto3 optional fields HOT 1
- Generate grpc-web code that use import than require HOT 5
- Error of protoc compiles FieldOption when using a enum from other proto
- Why is there no off() method on ResponseStream ?
- Does it support generating ES6 specification JS files and using them in grPC-Web
- protobuf v21 can't find protoc-gen-js HOT 3
- Module not found error while importing from _pb.d.ts file
- Getting the string name of Protobuf object
- Trailing underscore, toObject produces object that does not conform to AsObject
- The proper user code
- no set method TS types for proto3 Map field
- Typing for repeated extension fields generated incorrectly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-protoc-gen.