Giter VIP home page Giter VIP logo

Comments (18)

webdevelopland avatar webdevelopland commented on May 25, 2024 24

@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.

delaneyj avatar delaneyj commented on May 25, 2024 19

@YPhyu add .cmd to the end of it and it works (using this locally on a Win10 computer)

from ts-protoc-gen.

FatimahJay avatar FatimahJay commented on May 25, 2024 1

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.

richw-kai avatar richw-kai commented on May 25, 2024 1

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.

YPhyu avatar YPhyu commented on May 25, 2024

Thanks. It works fine now.

from ts-protoc-gen.

bonnyr avatar bonnyr commented on May 25, 2024

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.

YPhyu avatar YPhyu commented on May 25, 2024

@bonnyr the plugin (protoc-gen-ts.cmd not ts-protoc-gen.cmd) is under node_modules\.bin

from ts-protoc-gen.

bonnyr avatar bonnyr commented on May 25, 2024

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.

YPhyu avatar YPhyu commented on May 25, 2024

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.

bonnyr avatar bonnyr commented on May 25, 2024

My bad - thanks for this. It's working now

from ts-protoc-gen.

unsafePtr avatar unsafePtr commented on May 25, 2024

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.

forconz avatar forconz commented on May 25, 2024

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.

forconz avatar forconz commented on May 25, 2024

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.

forconz avatar forconz commented on May 25, 2024
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.

forconz avatar forconz commented on May 25, 2024
# 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.

forconz avatar forconz commented on May 25, 2024
# 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.

amarwavare avatar amarwavare commented on May 25, 2024

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.

orenkuper avatar orenkuper commented on May 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.