{"id":10975,"library":"grpc-inspect","title":"gRPC Protocol Buffer Inspector","description":"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`.","status":"abandoned","version":"0.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/bojand/grpc-inspect","tags":["javascript","protocol buffer","protobuf","grpc"],"install":[{"cmd":"npm install grpc-inspect","lang":"bash","label":"npm"},{"cmd":"yarn add grpc-inspect","lang":"bash","label":"yarn"},{"cmd":"pnpm add grpc-inspect","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for loading protobuf definitions. This package is deprecated and superseded by `@grpc/grpc-js` and `@grpc/proto-loader`.","package":"grpc","optional":false}],"imports":[{"note":"The package is primarily designed for CommonJS (`require`). Direct ESM `import` is not supported and will fail.","wrong":"import grpcInspect from 'grpc-inspect';","symbol":"grpcInspect","correct":"const grpcInspect = require('grpc-inspect');"},{"note":"Utility methods like `namespaceNames()` are available on the descriptor object returned by the main `grpc-inspect` function, not as top-level named exports.","wrong":"import { namespaceNames } from 'grpc-inspect';","symbol":"descriptor.namespaceNames","correct":"const gi = require('grpc-inspect');\nconst proto = grpc.load(pbpath);\nconst d = gi(proto);\nconst namespaces = d.namespaceNames();"}],"quickstart":{"code":"const grpcInspect = require('grpc-inspect');\nconst grpc = require('grpc');\nconst path = require('path');\nconst fs = require('fs');\n\n// Create a dummy .proto file for demonstration\nconst pbpath = path.resolve(__dirname, 'helloworld.proto');\nconst protoContent = `\nsyntax = \"proto3\";\n\npackage helloworld;\n\nservice Greeter {\n  rpc SayHello (HelloRequest) returns (HelloReply) {}\n}\n\nmessage HelloRequest {\n  string name = 1;\n}\n\nmessage HelloReply {\n  string message = 1;\n}`;\n\nfs.writeFileSync(pbpath, protoContent);\n\ntry {\n  // Load the protobuf definition using the deprecated 'grpc' package\n  const proto = grpc.load(pbpath);\n\n  // Inspect the loaded protobuf definition\n  const descriptor = grpcInspect(proto);\n\n  console.log('--- Namespaces ---');\n  console.dir(descriptor.namespaceNames());\n\n  console.log('\\n--- Services in helloworld namespace ---');\n  console.dir(descriptor.serviceNames('helloworld'));\n\n  console.log('\\n--- Greeter service methods ---');\n  console.dir(descriptor.methods('Greeter'));\n\n  console.log('\\n--- Full Descriptor Object (truncated) ---');\n  // console.dir(descriptor, { depth: null }); // Uncomment for full object\n  console.dir(descriptor.namespaces.helloworld.messages.HelloRequest); // Example message inspection\n\n} catch (error) {\n  console.error('Error loading or inspecting proto:', error.message);\n  console.error('This package uses the deprecated `grpc` module, which may cause issues with modern Node.js versions or `@grpc/grpc-js`.');\n} finally {\n  // Clean up the dummy proto file\n  fs.unlinkSync(pbpath);\n}","lang":"javascript","description":"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."},"warnings":[{"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).","message":"The `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.","severity":"breaking","affected_versions":">=0.6.0"},{"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.","message":"This 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.","severity":"breaking","affected_versions":">=0.6.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.6.0"},{"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.","message":"Loading `.proto` files requires careful path resolution, especially when using `grpc.load`. Relative paths might not resolve as expected in different execution environments.","severity":"gotcha","affected_versions":">=0.6.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"You are likely using `@grpc/grpc-js` which does not expose `grpc.load` directly. Instead, `proto-loader` is used for loading `.proto` files.","error":"TypeError: grpc.load is not a function"},{"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.","cause":"The `grpc` package, which `grpc-inspect` depends on, is not installed or cannot be resolved in your project.","error":"Error: Cannot find module 'grpc'"},{"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');`.","cause":"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.","error":"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."}],"ecosystem":"npm"}