When using [grpc-tools](https://www.npmjs.com/package/grpc-tools)
to create generated Node.js files, you have three options the --grpc_out
flag:
- grpc_js: Generates code with require('@grpc/grpc-js') instead of require('grpc')
- generate_package_definition: Generates code that does not require any gRPC library, and instead generates PackageDefinition objects that can be passed to the loadPackageDefinition function provided by both the grpc and @grpc/grpc-js libraries.
- no option: Generates code with require('grpc')
Using the grpc_js
or no option actually triggers protoc
to create a generic client in the *_grpc_pb.js
file:
exports.RouteGuideClient = grpc.makeGenericClientConstructor(RouteGuideService);
What I found was that you need to use the same instance of gRPC (not just the same version) for them to work together. This will not be a problem if you are declaring you protos, generated files, and clients all in the same project. However, I have mine spread in different npm packages, so I did not use this functionality.
Top comments (0)