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());
}
});
Errors
Common errors & fixes
Error: Cannot find module './generated/helloworld_grpc_pb'
Generated files are missing because protoc was not run.
fixRun the protoc command to generate files from your proto definition.
Error: Cannot find module '@grpc/grpc-js'
gRPC runtime not installed.
fixRun 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.
fixUse the generated setter methods (e.g., setName) as defined in the generated pb types.
Audit
Dependencies
grpc-toolsrequiredrequired to compile proto files and generate TypeScript definitions
protoc-gen-tsrequiredprotoc plugin that generates TypeScript types from proto files