I am able to generate JS and golang protobuf files, but not typescript. I keep getting an error that reads.
protoc-gen-ts: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--ts_out: protoc-gen-ts: Plugin failed with status code 1.
make: *** [proto-old] Error 1
package.json deps
"grpc-mp": "^1.0.1",
"grpc-tools": "^1.11.3",
"grpc_tools_node_protoc_ts": "^5.3.2",
"ts-proto": "^1.131.0",
"ts-protoc-gen": "^0.15.0",
"vscode-ws-jsonrpc": "^2.0.0",
command
protoc api.proto --proto_path=${PROJ_PATH}/proto \
--plugin=protoc-gen-grpc=${PROJ_PATH}/view/node_modules/.bin/grpc_tools_node_protoc_plugin \
--js_out=import_style=commonjs:${PROJ_PATH}/view/proto \
--plugin=${PROJ_PATH}/view/node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_out=${PROJ_PATH}/view/proto \
--ts_out=${PROJ_PATH}/view/proto
Oddly, the JS files generated do not did not generate a client server. However, I would rather use typescript in combination with vue.js. As for the backend server I am using GO, and it did generate the server connection code. Hopefully once the typescript generation works the code to create the client server will be generated.
Question:
What is wrong with my proto command? The plugin is there and it appears to be inline with the docs.
Advice?
---- update 1 ----
had a small typo, here is the update
protoc api.proto --proto_path=${PROJ_PATH}/proto \
--plugin=protoc-gen-grpc=${PROJ_PATH}/form/node_modules/.bin/grpc_tools_node_protoc_plugin \
--plugin=protoc-gen-ts=${PROJ_PATH}/form/proto \
--ts_out=service=grpc-web:${PROJ_PATH}/form/proto \
--js_out=import_style=commonjs:${PROJ_PATH}/form/proto
error:
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--ts_out: protoc-gen-ts: Plugin failed with status code 1.
For some reason I TS code will not generate. My goal is for the vue.js frontend to communicate with my go backend. I am only working with the directory "form" and "api" at the moment.
Here's an example from scratch:
Install protoc:
VERS="21.9"
ARCH="linux-x86_64"
ENDPOINT="https://github.com/protocolbuffers/protobuf/releases/download"
wget ${ENDPOINT}/v${VERS}/protoc-${VERS}-${ARCH}.zip \
-O ${PWD}/protoc-${VERS}-${ARCH}.zip && \
unzip \
protoc-${VERS}-${ARCH}.zip \
-d ${PWD}/protoc-${VERS}-${ARCH} && \
rm ${PWD}/protoc-${VERS}-${ARCH}.zip
PATH=${PATH}:${PWD}/protoc-${VERS}-${ARCH}/bin
package.json
:
{
"name": "74275480",
"version": "0.0.1",
"dependencies": {
"ts-protoc-gen": "^0.15.0"
}
}
Create NPM project:
npm install
PROTO="api.proto"
protoc \
--proto_path=${PWD} \
--plugin="protoc-gen-ts"=${PWD}/node_modules/.bin/protoc-gen-ts \
--ts_out=${PWD} \
${PWD}/${PROTO}
Then:
api_pb.d.ts # Output
api.proto
node_modules
package.json
package-lock.json
protoc-21.9-linux-x86_64