Registry / communication / grpc-js-v

grpc-js-v

JSON →
library1.0.1jsnpmunverified

Pure JavaScript implementation of gRPC for Node.js, maintained by the official gRPC team. Current version v1.0.1 supports Node >=12.10.0. Designed as a drop-in replacement for the deprecated grpc package (C++ addon), offering features such as client/server streaming, automatic reconnection, round-robin/pick-first load balancing, connection keepalives, HTTP CONNECT proxies, and partial compression. Does not handle .proto files directly, relying on @grpc/proto-loader instead. Ships TypeScript types. Updated regularly, with semver guarantees but some internal methods prefixed with underscores.

npm install grpc-js-v
INSTALL
IMPORT
SIG · GRPC-JS-V
G
grpc-js-v
communicationjavascriptv1.0.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.

grpc
import * as grpc from '@grpc/grpc-js'
const grpc = require('grpc')
The old grpc (C++ addon) is deprecated; use @grpc/grpc-js for pure JS.
loadPackageDefinition
import { loadPackageDefinition } from '@grpc/grpc-js'
const { loadPackageDefinition } = require('grpc')
Only available in @grpc/grpc-js; grpc.load is not supported.
Server
import { Server } from '@grpc/grpc-js'
const Server = require('grpc').Server
Server#bind is replaced by Server#bindAsync for async binding.
credentials
import { credentials } from '@grpc/grpc-js'
Same API as grpc package; use createInsecure or createSsl.

Creates a gRPC client from a .proto file, calls an RPC, and prints the response.

import * as grpc from '@grpc/grpc-js'; import * as protoLoader from '@grpc/proto-loader'; import { loadPackageDefinition } from '@grpc/grpc-js'; // Load proto file const packageDefinition = protoLoader.loadSync('helloworld.proto', { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true, }); const proto = loadPackageDefinition(packageDefinition).helloworld; // Create client const client = new proto.Greeter('localhost:50051', grpc.credentials.createInsecure()); // Call RPC client.sayHello({ name: 'World' }, (err, response) => { if (err) console.error(err); else console.log('Greeting:', response.message); });
Debug
Known issues
breakingServer#bind is replaced by Server#bindAsync
fix
Use server.bindAsync(port, creds, callback) instead of server.bind(port, creds)
affects: >=1.0.0
deprecatedThe grpc package (C++ addon) is deprecated in favor of @grpc/grpc-js
fix
Replace require('grpc') with require('@grpc/grpc-js') and adjust usage as per migration guide
affects: >=1.0.0
gotchagrpc.load is not available; use @grpc/proto-loader with loadPackageDefinition
fix
Replace grpc.load() with protoLoader.loadSync() + loadPackageDefinition()
affects: >=1.0.0
gotchaNot all channel options from grpc are supported; some will be ignored
fix
Check supported channel options list in docs; unknown options may silently fail
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'Greeter')
Client object not instantiated from loaded proto definition
fix
Ensure proto definition is loaded correctly, e.g., const proto = loadPackageDefinition(packageDefinition).helloworld;
Error: 1 UNKNOWN: No method handler for /helloworld.Greeter/SayHello
Server method not registered correctly
fix
Ensure the server has a handler for the service, e.g., server.addService(proto.Greeter.service, { sayHello: (call, callback) => { ... } })
Error: Cannot find module '@grpc/proto-loader'
Missing proto-loader dependency
fix
Install the dependency: npm install @grpc/proto-loader
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
@grpc/proto-loaderoptionalNeeded to load .proto files, as @grpc/grpc-js does not handle them directly
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
grpc-js-v — npm install grpc-js-v · libregistry