Registry / devops / grpc-js-consul

grpc-js-consul

JSON →
library1.3.1jsnpmunverified

A gRPC name resolver for @grpc/grpc-js that integrates with HashiCorp Consul service discovery. Version 1.3.1 is current; release cadence is irregular. It resolves service endpoints from Consul and watches for changes. Differentiators: minimal API (single register() call), supports Consul health checks, tagging, and advanced query parameters (wait, near, limit, stale, consistent). Note: not production-ready per the author; may break backward compatibility.

npm install grpc-js-consul
INSTALL
IMPORT
SIG · GRPC-JS-CONSUL
G
grpc-js-consul
devopsjavascriptv1.3.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.

register
import { register } from 'grpc-js-consul'
import register from 'grpc-js-consul'
Register is a named export, not default. ESM or CJS both work.
Resolver
import { Resolver } from 'grpc-js-consul'
import { Resolver } from 'grpc-js-consul/resolver'
Resolver class is exported from the main package, not a subpath. No types exported separately.
register function
const { register } = require('grpc-js-consul')
const register = require('grpc-js-consul').default
CommonJS users must destructure the named export; there is no default export.

Shows how to register the Consul resolver and create a gRPC client using a consul:// URI.

import { credentials } from '@grpc/grpc-js'; import { register } from 'grpc-js-consul'; // Register the Consul resolver register(); // Now you can use 'consul://' URIs in gRPC client construction const client = new SomeClient('consul://localhost:8500/my-service', credentials.createInsecure()); client.someMethod({}, (err, response) => { if (err) console.error(err); else console.log(response); });
Debug
Known issues
gotchaLibrary is not production-ready; may break backward compatibility between versions.
fix
Pin exact version and thoroughly test upgrades.
affects: all
gotchaConsul connection string must be formatted correctly; missing parameters can cause silent failures.
fix
Ensure consul://host:port/service-name?parameters format. See README for supported options.
affects: all
deprecatedThe old import path 'grpc-js-consul/build' may be removed in future versions.
fix
Use main package import: import { register } from 'grpc-js-consul'.
affects: >=1.0 <=1.3
gotchaVerbs like 'wait' and 'timeout' use Go's time.ParseDuration format, not ISO 8601.
fix
Use strings like '10s', '5m', '1h30m'.
affects: all
Errors
Common errors & fixes
TypeError: grpc-js-consul.register is not a function
Trying to use require() with a default import or wrong destructuring.
fix
Use const { register } = require('grpc-js-consul');
Error: No resolver found for consul://...
register() not called before client creation.
fix
Call register() at the top of your application.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredpeer dependency for gRPC client
Agent activity
8 hits · last 30 days
node
8
Resources
grpc-js-consul — npm install grpc-js-consul · libregistry