Registry / devops / ts-grpc-willw2

ts-grpc-willw2

JSON →
library1.0.5jsnpmunverified

A minimal template for generating TypeScript gRPC client and server code from proto files. Current version 1.0.5, released once as a proof-of-concept. It wraps the protoc-gen-ts plugin and provides a basic example. Not actively maintained; alternatives like grpc-tools or buf are more robust. Differentiator: simplifies initial setup for TypeScript users unfamiliar with gRPC code generation.

npm install ts-grpc-willw2
INSTALL
IMPORT
SIG · TS-GRPC-WILLW2
T
ts-grpc-willw2
devopsjavascriptv1.0.5
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.

GreeterClient
import { GreeterClient } from './generated/helloworld_grpc_pb';
import { GreeterClient } from 'ts-grpc-willw2';
The package itself does not export generated classes; you must import from your local generated files.
HelloRequest
import { HelloRequest } from './generated/helloworld_pb';
import { HelloRequest } from 'ts-grpc-willw2';
Protobuf message classes are generated into a pb file, not exported by this template package.
credentials
import { credentials } from '@grpc/grpc-js';
import { credentials } from 'ts-grpc-willw2';
Credentials are from the gRPC library, not this template.

Shows how to set up a gRPC client in TypeScript using generated code from this template, including proto compilation step.

// 1. Install dependencies // npm install ts-grpc-willw2 @grpc/grpc-js protoc-gen-ts // 2. Compile proto file using protoc with ts plugin // protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --ts_out=./generated --grpc_out=./generated hello.proto // 3. Use generated client in TypeScript: import { GreeterClient } from './generated/helloworld_grpc_pb'; import { HelloRequest } from './generated/helloworld_pb'; import { credentials } from '@grpc/grpc-js'; const client = new GreeterClient('localhost:50051', credentials.createInsecure()); const request = new HelloRequest(); request.setName('World'); client.sayHello(request, (error, response) => { if (!error) { console.log('Greeting:', response.getMessage()); } });
Debug
Known issues
gotchaThe package does not bundle the gRPC runtime or protoc itself; you must install @grpc/grpc-js and protoc separately.
fix
Add @grpc/grpc-js and protoc as dev dependencies.
affects: >=1.0.0
deprecatedprotoc-gen-ts is unmaintained; consider using @grpc/proto-loader or grpc-tools with grpc_tools_node_protoc_ts instead.
fix
Switch to @grpc/proto-loader for dynamic code generation.
affects: >=1.0.0
gotchaGenerated TypeScript files rely on @grpc/grpc-js and google-protobuf; ensure both are in dependencies.
fix
Run npm install @grpc/grpc-js google-protobuf
affects: >=1.0.0
gotchaThe template uses synchronous proto compilation; large proto files may cause slow builds.
fix
Consider using a build tool like protoc-gen-ts-es or buf for larger projects.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module './generated/helloworld_grpc_pb'
Generated files are missing because protoc was not run.
fix
Run the protoc command to generate files from your proto definition.
Error: Cannot find module '@grpc/grpc-js'
gRPC runtime not installed.
fix
Run npm install @grpc/grpc-js
TypeError: request.setName is not a function
Protobuf message generated with a getter/setter pattern; you may be using incorrect method names.
fix
Use the generated setter methods (e.g., setName) as defined in the generated pb types.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
grpc-toolsrequiredrequired to compile proto files and generate TypeScript definitions
protoc-gen-tsrequiredprotoc plugin that generates TypeScript types from proto files
Agent activity
6 hits · last 30 days
node
6
Resources
ts-grpc-willw2 — npm install ts-grpc-willw2 · libregistry