Registry / devops / grpc-modern

grpc-modern

JSON →
library0.5.1jsnpmunverified

A lightweight wrapper library (v0.5.1) that modernizes gRPC clients in Node.js by converting callback-based interfaces to Promises and replacing constructor + setter patterns with object literals. Works with both @grpc/grpc-js and grpc packages. No breaking changes since v0.1.0, stable and actively maintained. Differentiator: provides a clean, idiomatic TypeScript API for gRPC without requiring a full framework change.

npm install grpc-modern
INSTALL
IMPORT
SIG · GRPC-MODERN
G
grpc-modern
devopsjavascriptv0.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

makeModernClient
import { makeModernClient } from 'grpc-modern'
const makeModernClient = require('grpc-modern');
Library is ESM-only; CommonJS require() will error.
set
import { set } from 'grpc-modern'
import { set } from 'grpc-modern/set'; // incorrect path
The 'set' function is a named export, not a default export.
ModernClient
import type { ModernClient } from 'grpc-modern'
import { ModernClient } from 'grpc-modern'; // ModernClient is a type, not a value
Use type import to avoid runtime errors if transpiled.
default
import grpcModern from 'grpc-modern';
import * as grpcModern from 'grpc-modern'; // no default export
No default export exists; only named exports.

Creates a modern gRPC client using makeModernClient and builds request objects with set, then calls an RPC with async/await.

import * as grpc from '@grpc/grpc-js'; import { makeModernClient, set } from 'grpc-modern'; import { GetSomethingReq, SomethingClient } from './stubs/something'; const client = makeModernClient(SomethingClient, { address: 'example.com:80', credential: grpc.credentials.createInsecure(), }); const req = set(GetSomethingReq, { id: '123', someOption: true, }); const response = await client.getSomething(req); console.log(response);
Debug
Known issues
gotchaLibrary is ESM-only. Using require() throws a runtime error.
fix
Use import syntax or set type: 'module' in package.json.
affects: >=0.1.0
breakingThe 'set' function mutates the first argument (the message object).
fix
Pass a new instance each time to avoid unexpected mutations.
affects: >=0.1.0
deprecatedThe 'grpc' (legacy) package is deprecated. Use '@grpc/grpc-js' instead.
fix
Replace 'grpc' with '@grpc/grpc-js' as peer dependency.
affects: >=0.1.0
gotchaType 'ModernClient' is not exported as a value; attempting to use it at runtime causes a ReferenceError.
fix
Use 'import type { ModernClient } from 'grpc-modern''.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'grpc-modern'
Package not installed or incorrect import path.
fix
Run 'npm install grpc-modern' (or yarn) and ensure peer dependencies are installed.
TypeError: grpcModern.makeModernClient is not a function
Using default import instead of named import.
fix
Change import to 'import { makeModernClient } from 'grpc-modern''.
TypeError: Cannot read properties of undefined (reading 'getSomething')
The client was not created correctly; missing required options (address/credential).
fix
Ensure makeModernClient receives an object with 'address' (string) and 'credential' (grpc.ChannelCredentials).
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
@grpc/grpc-jsoptionalgRPC client library for modern Node.js
google-protobufrequiredProtobuf message types used by gRPC
@types/google-protobufoptionalTypeScript type definitions for google-protobuf
grpcoptionalLegacy gRPC client library (alternative to @grpc/grpc-js)
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
grpc-modern — npm install grpc-modern · libregistry