Registry / devops / grpc_tools_node_protoc_ts

grpc_tools_node_protoc_ts

JSON →
library5.3.3jsnpmunverified

Generates TypeScript definition files (.d.ts) from JavaScript code produced by grpc_tools_node_protoc (protoc plugin for Node.js gRPC). Current stable version 5.3.3 supports @grpc/grpc-js and requires grpc-tools >=1.9.0. The tool bridges gRPC protobuf code generation and TypeScript, providing type safety for gRPC clients and servers. It includes breaking changes across major versions, with v5 dropping support for older grpc-tools and @grpc/grpc-js versions. Compared to alternatives like @grpc/proto-loader, this package generates static type definitions rather than runtime dynamic types.

npm install grpc_tools_node_protoc_ts
INSTALL
IMPORT
SIG · GRPC_TOOLS_NODE_PR
G
grpc_tools_node_protoc_ts
devopsjavascriptv5.3.3
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.

ServiceClient
import { MyServiceClient } from './generated/my_grpc_pb.d.ts'
import MyServiceClient from './generated/my_grpc_pb'
Generated .d.ts files contain named exports from the same file as the JS, typically alongside message types.
Server
import { Server } from '@grpc/grpc-js'
const Server = require('@grpc/grpc-js').Server
Use named import from @grpc/grpc-js; avoid usage of deprecated 'grpc' package.
handleClientStreamingCall
import { handleClientStreamingCall } from '@grpc/grpc-js'
import { handleClientStreamingCall } from '@grpc/grpc-js/build/src/server-call'
Since @grpc/grpc-js@1.2.0 this is no longer necessary; the type is exported via the main module.

Installs required packages, generates JS and d.ts files from .proto, then uses the typed client in a TypeScript application.

// Install: npm install grpc-tools @grpc/grpc-js google-protobuf grpc_tools_node_protoc_ts // Generate JS + d.ts: // grpc_tools_node_protoc --js_out=import_style=commonjs,binary:./generated --grpc_out=grpc_js:./generated --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc` ./proto/example.proto // grpc_tools_node_protoc_ts --proto_path ./proto --output ./generated example.proto // Use generated client: import { ExampleServiceClient } from './generated/example_grpc_pb'; import { ExampleRequest } from './generated/example_pb'; const client = new ExampleServiceClient('localhost:8080', grpc.credentials.createInsecure()); const req = new ExampleRequest(); client.myRpc(req, (err, response) => { if (!err) console.log(response.getMessage()); });
Debug
Known issues
breakingv5.3.0: Removed import of handleClientStreamingCall from @grpc/grpc-js/build/src/server-call; now must be imported from '@grpc/grpc-js'. @grpc/grpc-js >=1.2.0 required.
fix
Upgrade @grpc/grpc-js to >=1.2.0 and change imports to '@grpc/grpc-js'.
affects: >=5.3.0
breakingv5.2.0: Proto3 'optional' support requires grpc-tools >=1.11.1. Older versions will not generate correct d.ts.
fix
Upgrade grpc-tools to >=1.11.1.
affects: >=5.2.0
breakingv4.0.0: Dropped support for grpc-tools <1.9.0. Also requires google-protobuf >=3.10.0 for chain setters.
fix
Upgrade grpc-tools to >=1.9.0 and google-protobuf to >=3.10.0.
affects: >=4.0.0
breakingv2.4.0: Return type of ClientReadableStream was wrong; fixed to use proper gRPC types.
fix
Update code if it relied on the incorrect stream type.
affects: >=2.4.0
deprecatedThe 'grpc' package is deprecated; use '@grpc/grpc-js' instead. grpc_tools_node_protoc_ts v5+ only supports @grpc/grpc-js.
fix
Replace 'grpc' with '@grpc/grpc-js' and update imports.
affects: >=5.0.0
Errors
Common errors & fixes
Error: Cannot find module 'grpc_tools_node_protoc_ts'
Package not installed or global install missing PATH
fix
Install locally: npm install --save-dev grpc_tools_node_protoc_ts
Or install globally: npm install -g grpc_tools_node_protoc_ts
TypeError: client.myRpc is not a function
Protobuf JS files not generated correctly or client creation issue
fix
Ensure grpc_tools_node_protoc generated JS files with --grpc_out=grpc_js and --js_out=import_style=commonjs,binary. Verify .proto service definition.
Module not found: Error: Can't resolve '@grpc/grpc-js'
@grpc/grpc-js not installed
fix
npm install @grpc/grpc-js
Protobuf type 'optional' not allowed in proto3
Proto syntax not set to proto3 or grpc-tools too old
fix
Set syntax = 'proto3'; in .proto and upgrade grpc-tools to >=1.11.1.
Upgrade
Version history
5.3.3latest on npm
Audit
Dependencies
grpc-toolsrequiredRequired protoc plugin for generating JS files from .proto
google-protobufrequiredRuntime dependency for protobuf message classes
@grpc/grpc-jsoptionalgRPC client/server library for Node.js (replaces grpc)
Agent activity
6 hits · last 30 days
node
6
Resources
grpc_tools_node_protoc_ts — npm install grpc_tools_node_protoc_ts · libregistry