Registry / serialization / grpc-inspect

grpc-inspect

JSON →
library0.6.0jsnpmunverified

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-inspect
INSTALL
IMPORT
SIG · GRPC-INSPECT
G
grpc-inspect
serializationjavascriptv0.6.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

grpcInspect
✓ const grpcInspect = require('grpc-inspect');
✗ import grpcInspect from 'grpc-inspect';
The package is primarily designed for CommonJS (`require`). Direct ESM `import` is not supported and will fail.
descriptor.namespaceNames
✓ const gi = require('grpc-inspect'); const proto = grpc.load(pbpath); const d = gi(proto); const namespaces = d.namespaceNames();
✗ import { namespaceNames } from 'grpc-inspect';
Utility methods like `namespaceNames()` are available on the descriptor object returned by the main `grpc-inspect` function, not as top-level named exports.

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.

const grpcInspect = require('grpc-inspect'); const grpc = require('grpc'); const path = require('path'); const fs = require('fs'); // Create a dummy .proto file for demonstration const pbpath = path.resolve(__dirname, 'helloworld.proto'); const protoContent = ` syntax = "proto3"; package helloworld; service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) {} } message HelloRequest { string name = 1; } message HelloReply { string message = 1; }`; fs.writeFileSync(pbpath, protoContent); try { // Load the protobuf definition using the deprecated 'grpc' package const proto = grpc.load(pbpath); // Inspect the loaded protobuf definition const descriptor = grpcInspect(proto); console.log('--- Namespaces ---'); console.dir(descriptor.namespaceNames()); console.log('\n--- Services in helloworld namespace ---'); console.dir(descriptor.serviceNames('helloworld')); console.log('\n--- Greeter service methods ---'); console.dir(descriptor.methods('Greeter')); console.log('\n--- Full Descriptor Object (truncated) ---'); // console.dir(descriptor, { depth: null }); // Uncomment for full object console.dir(descriptor.namespaces.helloworld.messages.HelloRequest); // Example message inspection } catch (error) { console.error('Error loading or inspecting proto:', error.message); console.error('This package uses the deprecated `grpc` module, which may cause issues with modern Node.js versions or `@grpc/grpc-js`.'); } finally { // Clean up the dummy proto file fs.unlinkSync(pbpath); }
Debug
Known issues
breakingThe `grpc-inspect` package heavily relies on the deprecated `grpc` npm package for loading `.proto` files. The `grpc` package has been superseded by `@grpc/grpc-js` and `@grpc/proto-loader`, which have different APIs and behaviors. Using `grpc-inspect` with modern gRPC setups (e.g., `@grpc/grpc-js`) will likely require significant refactoring or may not be directly compatible.
fix
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).
affects: >=0.6.0
breakingThis package is effectively abandoned, with its last update over seven years ago. It is not maintained and may have unaddressed bugs, security vulnerabilities, or incompatibilities with newer Node.js versions or underlying system libraries.
fix
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.
affects: >=0.6.0
gotchaThe package uses CommonJS (`require`) syntax and does not officially support ES Modules (`import`). Attempting to `import` it directly in an ESM context will result in errors.
fix
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.
affects: >=0.6.0
gotchaLoading `.proto` files requires careful path resolution, especially when using `grpc.load`. Relative paths might not resolve as expected in different execution environments.
fix
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.
affects: >=0.6.0
Errors
Common errors & fixes
TypeError: grpc.load is not a function
You are likely using `@grpc/grpc-js` which does not expose `grpc.load` directly. Instead, `proto-loader` is used for loading `.proto` files.
fix
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.
Error: Cannot find module 'grpc'
The `grpc` package, which `grpc-inspect` depends on, is not installed or cannot be resolved in your project.
fix
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.
SyntaxError: Named export 'grpcInspect' not found. The requested module 'grpc-inspect' is a CommonJS module, which may not support all module.exports as named exports.
You are attempting to `import grpcInspect from 'grpc-inspect'` in an ES Module context, but `grpc-inspect` is a CommonJS module and does not provide named ESM exports.
fix
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');`.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies
grpcrequiredCore dependency for loading protobuf definitions. This package is deprecated and superseded by `@grpc/grpc-js` and `@grpc/proto-loader`.
Agent activity
10 hits · last 30 days
node
10
Resources