The `etcd3` library provides a robust, production-ready Node.js client for the etcd v3 API, which is based on Protocol Buffers. Currently at stable version `1.1.2`, the project demonstrates an active release cadence with frequent patch and minor updates, typically every few weeks to months. Key differentiators include comprehensive features such as intelligent load balancing, resilient fault handling with automatic reconnections (leveraging Cockatiel), atomic transactions, Software Transactional Memory (STM), high-level query builders, sophisticated lease management, real-time watchers, user and role administration, and leader election mechanisms. It also offers full type-safety for TypeScript users, ensuring a robust development experience, and is maintained by Microsoft.
npm install etcd3Verified import paths — ran on the pinned version, not inferred.
This example initializes an `etcd3` client, connects to an etcd server, demonstrates putting and getting a key-value pair, querying keys with a prefix, and finally deleting all keys. It includes basic error handling and uses `ETCD_ADDR` for host configuration.
Upgrade to `etcd3@1.1.2` or newer to incorporate the fix.
Ensure all watcher event listener callbacks are robustly error-handled. Upgrade to `etcd3@1.1.0` or newer, which includes a fix to prevent this from affecting the underlying stream.
Upgrade to `etcd3@1.1.0` or newer for correct Buffer typings. For older versions, type assertions might be necessary, but this is not recommended.
Upgrade to `etcd3@1.0.2` or newer, which includes an updated `cockatiel` version resolving these type conflicts.
Ensure an etcd server is running and accessible. Set `export ETCD_ADDR=localhost:2379` (or your etcd host:port) before running applications or tests that connect to etcd.
Verify that your etcd server is running and listening on the expected host and port. Ensure the `ETCD_ADDR` environment variable or the `hosts` option in the `Etcd3` client constructor is correctly set to your etcd endpoint (e.g., '127.0.0.1:2379').
When using ES Modules (type: 'module' in package.json or .mjs files), use `import { Etcd3 } from 'etcd3';`. If using CommonJS, ensure your environment properly handles the module export or consider using `require('etcd3').Etcd3` if applicable, although ESM is preferred.