Registry / devops / ts-protoc-gen

ts-protoc-gen

JSON →
library0.15.0jsnpmunverified

A protoc plugin for generating TypeScript declarations and service definitions from Protocol Buffers (proto3). Version 0.15.0 is the latest stable release. It works alongside protoc to produce .ts files (including gRPC service stubs) and has been widely used but is now in maintenance mode, with alternatives like protobuf-ts or buf's protoc-gen-es recommended. Key differentiator: direct integration with protoc for TypeScript/JavaScript projects.

npm install ts-protoc-gen
INSTALL
IMPORT
SIG · TS-PROTOC-GEN
T
ts-protoc-gen
devopsjavascriptv0.15.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

protoc-gen-ts
// usage via protoc command line: --ts_out=outdir
import { something } from 'ts-protoc-gen'
This is a protoc plugin executable, not a runtime library. It should be invoked via protoc with --ts_out, not imported in code.
grpc
import * as grpc from '@grpc/grpc-js';
import grpc from 'grpc';
The 'grpc' package is deprecated; use '@grpc/grpc-js' for gRPC client/server in Node.js.
service definitions
import { MyServiceClient } from './proto/my_pb_service';
import { MyService } from './proto/my_pb';
Generated service client classes are in _pb_service files; message types are in _pb files.

Shows how to install ts-protoc-gen, run protoc to generate TypeScript files, and use the generated gRPC service client.

// 1. Install protoc (https://github.com/protocolbuffers/protobuf/releases) // 2. Install ts-protoc-gen globally or as dev dependency npm install -g ts-protoc-gen // or local: npm install --save-dev ts-protoc-gen // 3. Run protoc with ts-protoc-gen plugin protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --ts_out=./generated --proto_path=./protos ./protos/*.proto // 4. Generated files: mymessage_pb.ts, myservice_pb_service.ts // 5. Use generated code (example Node.js gRPC client): import * as grpc from '@grpc/grpc-js'; import { MyServiceClient } from './generated/myservice_pb_service'; const client = new MyServiceClient('localhost:50051', grpc.credentials.createInsecure());
Debug
Known issues
gotchats-protoc-gen requires protoc to be installed separately; it is not included in the npm package.
fix
Install protoc from https://github.com/protocolbuffers/protobuf/releases
affects: >=0.0.1
gotchaGenerated .ts files may require manual import of google-protobuf for certain features (e.g., Any, Timestamp).
fix
Install google-protobuf: npm install google-protobuf, then import as needed.
affects: <0.15.0
deprecatedThe package is in maintenance mode; consider migrating to protobuf-ts or buf's protoc-gen-es for better TypeScript support.
fix
Evaluate alternatives: protobuf-ts (https://github.com/timostamm/protobuf-ts) or protoc-gen-es (https://github.com/bufbuild/protoc-gen-es)
affects: >=0.0.0
gotchaWhen using gRPC, ensure @grpc/grpc-js (or grpc) is installed as a runtime dependency; ts-protoc-gen only generates TypeScript definitions.
fix
npm install @grpc/grpc-js
affects: >=0.0.0
gotchaWindows users: the protoc-gen-ts binary may not work directly; use WSL or specify full path to node executable.
fix
Use: --plugin=protoc-gen-ts=.\node_modules\.bin\protoc-gen-ts.cmd
affects: >=0.0.0
Errors
Common errors & fixes
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.
protoc cannot find the ts-protoc-gen plugin.
fix
Specify the full path to the plugin: --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts
error TS2694: Namespace '...' has no exported member '...'.
Generated TypeScript files may have dependencies on google-protobuf or other packages not imported.
fix
Install google-protobuf and import necessary types: npm install google-protobuf
Error: Cannot find module 'google-protobuf'
Generated code references google-protobuf but it is not installed.
fix
npm install google-protobuf
TypeError: grpc.loadPackageDefinition is not a function
Using grpc package (deprecated) with newer @grpc/grpc-js API.
fix
Switch to @grpc/grpc-js and use its loadPackageDefinition.
Upgrade
Version history
0.15.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
ts-protoc-gen — npm install ts-protoc-gen · libregistry