> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js SDK - Installation

> Register the GitLab npm registry and install the Node.js SDK.

The `@westyx-nexus/sdk-nodejs` package is hosted on the [GitLab npm Package Registry](https://gitlab.com/westyx/nexus/sdk/nodejs/-/packages). It is **public** - no token is required to install.

## 1. Configure npm to look at the registry

Add (or merge) the following to your project's `.npmrc`:

```ini theme={null}
@westyx-nexus:registry=https://gitlab.com/api/v4/projects/81979824/packages/npm/
```

<Info>
  Commit the `.npmrc` to source control. It contains no credentials - every developer on the team automatically picks up the right registry.
</Info>

## 2. Install the package

```sh theme={null}
npm install @westyx-nexus/sdk-nodejs
```

Pin to a specific version:

```sh theme={null}
npm install @westyx-nexus/sdk-nodejs@0.10.0
```

## Requirements

* **Node.js 18.0** or newer (LTS). Earlier versions are not tested and will likely fail on global `fetch`-style helpers and ES2022+ features used internally.
* TypeScript users: any version supporting ES2022 target is fine. Type definitions ship in the package.

## Importing

The package exposes a CommonJS build under `dist/`. Both `import` (ES modules) and `require` (CommonJS) work:

<CodeGroup>
  ```ts title="ES Modules / TypeScript" theme={null}
  import { NexusClient } from '@westyx-nexus/sdk-nodejs';
  ```

  ```js title="CommonJS" theme={null}
  const { NexusClient } = require('@westyx-nexus/sdk-nodejs');
  ```
</CodeGroup>

## Verifying connectivity

Before writing any code, confirm your endpoint and API key work with a plain `curl`:

```sh theme={null}
curl -s \
  -H "X-Nexus-API-Key: wxs_..." \
  https://your-service.westyx.dev/v1/sync
```

A valid response returns a JSON snapshot with your `configs`, `secrets`, and `flags`. An `HTTP 401` means the key is wrong; `HTTP 404` means the slug is wrong.

To watch the live SSE stream:

```sh theme={null}
curl -N \
  -H "X-Nexus-API-Key: wxs_..." \
  -H "Accept: text/event-stream" \
  https://your-service.westyx.dev/v1/stream
```

You should see `event:resync` arrive within a second. Press `Ctrl+C` to stop.

## Troubleshooting

* **`Could not resolve '@westyx-nexus/sdk-nodejs'`** - your `.npmrc` is not picked up. Confirm it's at the project root next to `package.json`, and check `npm config get registry @westyx-nexus`.
* **`401 Unauthorized` when running `npm install`** - the registry may be configured with an old path that's no longer valid. Switch to the numeric-ID variant above.
* **`ERR_REQUIRE_ESM`** - you tried to `require()` an ESM-only build. The SDK ships CJS; if you see this, double-check the import path.
