Streamerbot / client

Streamer.bot WebSocket client
https://streamerbot.github.io/client/
MIT License
23 stars 4 forks source link

Reference errors when running client in node app #1

Closed zephsinx closed 1 year ago

zephsinx commented 1 year ago

I am running into ReferenceError errors when trying to use the @streamerbot/client inside of a simple Node app. Specifically, WebSockets, and sometimes Crypto, can't be found. Hopefully I'm just missing something simple.

The Code

This is the entirety of the code I am trying.

import { StreamerbotClient } from '@streamerbot/client';
const sbClient = new StreamerbotClient();
const myActions = await sbClient.getActions();

The Error

When running it, I get the following error:

file:///sb-client/node_modules/@streamerbot/client/dist/index.js:154
  return `sb:client:req:${Date.now()}-${crypto.getRandomValues(new Uint32Array(12))[0]}`;
                                        ^

ReferenceError: crypto is not defined
    at generateRequestId (file:///sb-client/node_modules/←[4m@streamerbot←[24m/client/dist/index.js:154:41)
    at StreamerbotClient.<anonymous> (file:///sb-client/node_modules/←[4m@streamerbot←[24m/client/dist/index.js:336:14)
    at Generator.next (<anonymous>)
    at file:///sb-client/node_modules/←[4m@streamerbot←[24m/client/dist/index.js:37:61
    at new Promise (<anonymous>)
    at __async (file:///sb-client/node_modules/←[4m@streamerbot←[24m/client/dist/index.js:21:10)
    at StreamerbotClient.request (file:///sb-client/node_modules/←[4m@streamerbot←[24m/client/dist/index.js:334:12)
    at StreamerbotClient.<anonymous> (file:///sb-client/node_modules/←[4m@streamerbot←[24m/client/dist/index.js:487:25)
    at Generator.next (<anonymous>)
    at file:///sb-client/node_modules/←[4m@streamerbot←[24m/client/dist/index.js:37:61

I also ran multiple iterations of npm install to try and make sure things were installed

Thank you in advance! Again, hopefully it's something simple I'm missing.

Whipstickgostop commented 1 year ago

Thanks for the detailed report!

This has been fixed with v1.0.1