# nacos-naming

> nacos (https://nacos.io/en-us/) nodejs sdk

Latest version **2.6.3** (published 2026-06-16) · Apache license · 0 weekly downloads

## Install

```sh
npm install nacos-naming
pnpm add nacos-naming
yarn add nacos-naming
bun add nacos-naming
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.6.3 |
| Published | 2026-06-16 |
| First published | 2018-12-03 |
| Weekly downloads | 0 |
| License | Apache |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 8.0.0 |
| Dependencies | 7 |
| Unpacked size | 56.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 327 |
| Author | gxcsoccer |
| Maintainers | czy88840616, gxcsoccer, sunrisea |
| Keywords | nacos, cloud, native, eggjs |

## Links

- npm: https://www.npmjs.com/package/nacos-naming
- Repository: https://github.com/nacos-group/nacos-sdk-nodejs
- Homepage: https://github.com/nacos-group/nacos-sdk-nodejs#readme
- Issues: https://github.com/nacos-group/nacos-sdk-nodejs/issues
- npm.io page: https://npm.io/package/nacos-naming

## Dependencies (7)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [equals](https://npm.io/package/equals.md) ^1.0.5
- [urllib](https://npm.io/package/urllib.md) ^2.33.3
- [address](https://npm.io/package/address.md) ^1.1.0
- [utility](https://npm.io/package/utility.md) ^1.16.1
- [sdk-base](https://npm.io/package/sdk-base.md) ^3.6.0
- [mz-modules](https://npm.io/package/mz-modules.md) ^2.1.0

## Recent versions

- 2.6.3 (latest) — 2026-06-16
- 2.6.2 — 2026-05-12
- 2.6.1 — 2026-02-11
- 2.6.0 — 2023-12-14
- 2.5.0 — 2022-08-21
- 2.4.2 — 2022-08-09
- 2.4.1 — 2022-05-09
- 2.3.1 — 2022-04-25
- 2.3.0 — 2022-04-25
- 2.1.1 — 2021-05-11
- 2.1.0 — 2021-02-19
- 2.0.1 — 2021-01-26
- 2.0.0 — 2019-05-07
- 1.1.2 — 2019-03-31
- 1.1.1 — 2019-01-17
- … 3 more at https://npm.io/package/nacos-naming/versions

## README

# nacos-sdk-nodejs
=======

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![David deps][david-image]][david-url]

[npm-image]: https://img.shields.io/npm/v/ali-ons.svg?style=flat-square
[npm-url]: https://npmjs.org/package/ali-ons
[travis-image]: https://img.shields.io/travis/ali-sdk/ali-ons.svg?style=flat-square
[travis-url]: https://travis-ci.org/ali-sdk/ali-ons
[david-image]: https://img.shields.io/david/ali-sdk/ali-ons.svg?style=flat-square
[david-url]: https://david-dm.org/ali-sdk/ali-ons


[Nacos](https://nacos.io/en-us/) Node.js SDK

## Install

```bash
npm install nacos --save
```

## Usage

### Service Discovery

```js
'use strict';

const NacosNamingClient = require('nacos').NacosNamingClient;
const logger = console;

const client = new NacosNamingClient({
  logger,
  serverList: '127.0.0.1:8848', // replace to real nacos serverList
  namespace: 'public',
});
await client.ready();

const serviceName = 'nodejs.test.domain';

// registry instance
await client.registerInstance(serviceName, {
  ip: '1.1.1.1',
  port: 8080,
});
await client.registerInstance(serviceName, {
  ip: '2.2.2.2',
  port: 8080,
});

// subscribe instance
client.subscribe(serviceName, hosts => {
  console.log(hosts);
});

// deregister instance
await client.deregisterInstance(serviceName, {
  ip: '1.1.1.1',
  port: 8080,
});
```

## APIs

### Service Discovery

- `registerInstance(serviceName, instance, [groupName])`  Register an instance to service.
  - serviceName {String} Service name
  - instance {Instance}
    - ip {String} IP of instance
    - port {Number} Port of instance
    - [weight] {Number} weight of the instance, default is 1.0
    - [ephemeral] {Boolean} active until the client is alive, default is true
    - [clusterName] {String} Virtual cluster name
  - [groupName] {String} group name, default is `DEFAULT_GROUP`
- `deregisterInstance(serviceName, ip, port, [cluster])`  Delete instance from service.
  - serviceName {String} Service name
  - instance {Instance}
    - ip {String} IP of instance
    - port {Number} Port of instance
    - [weight] {Number} weight of the instance, default is 1.0
    - [ephemeral] {Boolean} active until the client is alive, default is true
    - [clusterName] {String} Virtual cluster name
  - [groupName] {String} group name, default is `DEFAULT_GROUP`
- `getAllInstances(serviceName, [groupName], [clusters], [subscribe])`  Query instance list of service.
  - serviceName {String} Service name
  - [groupName] {String} group name, default is `DEFAULT_GROUP`
  - [clusters] {String} Cluster names
  - [subscribe] {Boolean} whether subscribe the service, default is true
- `getServerStatus()` Get the status of nacos server, 'UP' or 'DOWN'.
- `subscribe(info, listener)` Subscribe the instances of the service
  - info {Object}|{String} service info, if type is string, it's the serviceName
  - listener {Function} the listener function
- `unSubscribe(info, [listener])` Unsubscribe the instances of the service
  - info {Object}|{String} service info, if type is string, it's the serviceName
  - listener {Function} the listener function, if not provide, will unSubscribe all listeners under this service

## Questions & Suggestions

Please let us know how can we help. Do check out [issues](https://github.com/nacos-group/nacos-sdk-nodejs/issues) for bug reports or suggestions first.

PR is welcome.

## License

[Apache License V2](LICENSE)

---
_Source: https://npm.io/package/nacos-naming · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
