Unleash / unleash-client-node

Unleash client SDK for Node.js
https://docs.getunleash.io
Apache License 2.0
210 stars 71 forks source link

Property 'on' does not exist on type 'Unleash'.ts(2339) #650

Closed marco-carvalho closed 1 month ago

marco-carvalho commented 1 month ago

Describe the bug

Property 'on' does not exist on type 'Unleash'.ts(2339)

Steps to reproduce the bug

  1. yarn create vite app1 --template react-ts
  2. npm install unleash-client
  3. code src/unleashClient.ts
  4. Put this:
    
    import { initialize } from 'unleash-client';

const unleashClient = initialize({ url: import.meta.env.VITE_UNLEASH_API_URL, appName: import.meta.env.VITE_UNLEASH_APP_NAME, customHeaders: { Authorization: import.meta.env.VITE_UNLEASH_API_TOKEN }, environment: import.meta.env.VITE_UNLEASH_ENV, });

unleashClient.on('ready', console.log);

export default unleashClient;



### Expected behavior

_No response_

### Logs, error output, etc.

_No response_

### Screenshots

_No response_

### Additional context

_No response_

### Unleash version

6.1.1

### Subscription type

None

### Hosting type

None

### SDK information (language and version)

_No response_
ivarconr commented 1 month ago

Hi there. The Node SDK is expected to run in an node environment. Unleash extends the EventEmitter, which only exists on Node.js and not in the browser.

To me it looks like you are trying to use the node SDK in a react application? In that case you are probably better off using the react SDK: https://github.com/Unleash/proxy-client-react