{"id":48103,"library":"grpc_tools_node_protoc_ts","title":"grpc_tools_node_protoc_ts","description":"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.","status":"active","version":"5.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/agreatfool/grpc_tools_node_protoc_ts","tags":["javascript","TypeScript","gRPC","protobuf","protoc","grpc_tools_node_protoc"],"install":[{"cmd":"npm install grpc_tools_node_protoc_ts","lang":"bash","label":"npm"},{"cmd":"yarn add grpc_tools_node_protoc_ts","lang":"bash","label":"yarn"},{"cmd":"pnpm add grpc_tools_node_protoc_ts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required protoc plugin for generating JS files from .proto","package":"grpc-tools","optional":false},{"reason":"Runtime dependency for protobuf message classes","package":"google-protobuf","optional":false},{"reason":"gRPC client/server library for Node.js (replaces grpc)","package":"@grpc/grpc-js","optional":true}],"imports":[{"note":"Generated .d.ts files contain named exports from the same file as the JS, typically alongside message types.","wrong":"import MyServiceClient from './generated/my_grpc_pb'","symbol":"ServiceClient","correct":"import { MyServiceClient } from './generated/my_grpc_pb.d.ts'"},{"note":"Use named import from @grpc/grpc-js; avoid usage of deprecated 'grpc' package.","wrong":"const Server = require('@grpc/grpc-js').Server","symbol":"Server","correct":"import { Server } from '@grpc/grpc-js'"},{"note":"Since @grpc/grpc-js@1.2.0 this is no longer necessary; the type is exported via the main module.","wrong":"import { handleClientStreamingCall } from '@grpc/grpc-js/build/src/server-call'","symbol":"handleClientStreamingCall","correct":"import { handleClientStreamingCall } from '@grpc/grpc-js'"}],"quickstart":{"code":"// Install: npm install grpc-tools @grpc/grpc-js google-protobuf grpc_tools_node_protoc_ts\n// Generate JS + d.ts:\n// 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\n// grpc_tools_node_protoc_ts --proto_path ./proto --output ./generated example.proto\n\n// Use generated client:\nimport { ExampleServiceClient } from './generated/example_grpc_pb';\nimport { ExampleRequest } from './generated/example_pb';\n\nconst client = new ExampleServiceClient('localhost:8080', grpc.credentials.createInsecure());\nconst req = new ExampleRequest();\nclient.myRpc(req, (err, response) => {\n  if (!err) console.log(response.getMessage());\n});","lang":"typescript","description":"Installs required packages, generates JS and d.ts files from .proto, then uses the typed client in a TypeScript application."},"warnings":[{"fix":"Upgrade @grpc/grpc-js to >=1.2.0 and change imports to '@grpc/grpc-js'.","message":"v5.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.","severity":"breaking","affected_versions":">=5.3.0"},{"fix":"Upgrade grpc-tools to >=1.11.1.","message":"v5.2.0: Proto3 'optional' support requires grpc-tools >=1.11.1. Older versions will not generate correct d.ts.","severity":"breaking","affected_versions":">=5.2.0"},{"fix":"Upgrade grpc-tools to >=1.9.0 and google-protobuf to >=3.10.0.","message":"v4.0.0: Dropped support for grpc-tools <1.9.0. Also requires google-protobuf >=3.10.0 for chain setters.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Update code if it relied on the incorrect stream type.","message":"v2.4.0: Return type of ClientReadableStream was wrong; fixed to use proper gRPC types.","severity":"breaking","affected_versions":">=2.4.0"},{"fix":"Replace 'grpc' with '@grpc/grpc-js' and update imports.","message":"The 'grpc' package is deprecated; use '@grpc/grpc-js' instead. grpc_tools_node_protoc_ts v5+ only supports @grpc/grpc-js.","severity":"deprecated","affected_versions":">=5.0.0"}],"env_vars":null,"search_vec":"'1.9.0':36 '5.3.3':28 'across':58 'altern':75 'break':56 'bridg':39 'chang':57 'client':51 'code':13,42 'compar':73 'current':25 'd.ts':10 'definit':8,83 'drop':63 'dynam':87 'file':9 'generat':6,43,80 'grpc':1,16,24,34,40,50,68,91,94 'grpc-tool':33,67 'grpc/grpc-js':30,71 'grpc/proto-loader':77 'includ':55 'javascript':12,89 'like':76 'major':59 'node':3,18,96 'node.js':23 'older':66 'packag':79 'plugin':21 'produc':14 'protobuf':41,92 'protoc':4,19,20,93,97 'provid':46 'rather':84 'requir':32 'runtim':86 'safeti':48 'server':53 'stabl':26 'static':81 'support':29,64 'tool':2,17,35,38,69,95 'ts':5 'type':47,82,88 'typescript':7,45,90 'v5':62 'version':27,60,72","created_at":"2026-06-07T16:54:56.302739+00:00","updated_at":"2026-06-07T16:54:56.302739+00:00","problems":[{"fix":"Install locally: npm install --save-dev grpc_tools_node_protoc_ts\nOr install globally: npm install -g grpc_tools_node_protoc_ts","cause":"Package not installed or global install missing PATH","error":"Error: Cannot find module 'grpc_tools_node_protoc_ts'"},{"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.","cause":"Protobuf JS files not generated correctly or client creation issue","error":"TypeError: client.myRpc is not a function"},{"fix":"npm install @grpc/grpc-js","cause":"@grpc/grpc-js not installed","error":"Module not found: Error: Can't resolve '@grpc/grpc-js'"},{"fix":"Set syntax = 'proto3'; in .proto and upgrade grpc-tools to >=1.11.1.","cause":"Proto syntax not set to proto3 or grpc-tools too old","error":"Protobuf type 'optional' not allowed in proto3"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/agreatfool/grpc_tools_node_protoc_ts#readme","github":"https://github.com/agreatfool/grpc_tools_node_protoc_ts","docs":null,"changelog":null,"pypi":null,"npm":"grpc_tools_node_protoc_ts","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}