grpc-inspect is a utility module for Node.js designed to parse and inspect gRPC Protocol Buffer definitions, generating a "friendlier" JavaScript object representation with helper methods. This allows developers to programmatically explore service methods, message structures, and field details loaded from `.proto` files. The current stable version, 0.6.0, was last published over seven years ago. The package is effectively abandoned, relying on the legacy `grpc` package for protobuf loading. Consequently, its utility is severely limited in modern gRPC environments and with current Node.js versions, making it unsuitable for new projects and likely problematic for existing ones that have upgraded their gRPC dependencies. Its primary differentiator was providing an easier-to-traverse descriptor object than the raw output of `grpc.load`.
npm install grpc-inspectVerified import paths — ran on the pinned version, not inferred.
Demonstrates loading a protobuf definition using the deprecated `grpc` package and then using `grpc-inspect` to generate and explore an inspectable descriptor object, showcasing namespace, service, and method introspection.
Consider alternatives like `@grpc/proto-loader` for protobuf introspection or tools like `grpcurl` for live service inspection. If `grpc-inspect` functionality is critical, you may need to implement custom parsing logic or downgrade your gRPC dependency (not recommended for production).
Avoid using this package for new projects. For existing projects, evaluate the risk of using unmaintained software and plan for migration to actively maintained alternatives.
If used in an ESM project, you must wrap it in a CommonJS context or use dynamic `import()` with caution, understanding the limitations. Ideally, migrate to ESM-first libraries for protobuf inspection.
Always use `path.resolve(__dirname, 'your_file.proto')` or similar robust path resolution methods to ensure the `.proto` file is found correctly, especially when deploying or running tests.
If you are using `@grpc/grpc-js`, you cannot use `grpc-inspect` directly as it depends on the old `grpc` package. Consider migrating your protobuf loading to `@grpc/proto-loader` and implement custom inspection logic, or use tools designed for modern gRPC.
Install the deprecated `grpc` package: `npm install grpc`. Be aware that this package is unmaintained and may have compatibility issues with newer Node.js versions.
Use the CommonJS `require` syntax: `const grpcInspect = require('grpc-inspect');`. If you must use it in an ESM file, you can try `import grpcInspect from 'grpc-inspect';` after configuring your bundler or Node.js to handle CJS imports, or use dynamic import `const grpcInspect = await import('grpc-inspect');`.