Mola19 / openrgb-sdk

A Nodejs SDK client for the RGB Software OpenRGB
MIT License
23 stars 4 forks source link

error #2

Closed makerio90 closed 3 years ago

makerio90 commented 3 years ago

code

const { Client } = require('openrgb-sdk');

async function start() {
    const client = new Client({
        host: 'localhost',
        port: 6742,
        name: 'Red Example',
    });

    await client.connect();
    const controllerCount = await client.getControllerCount();

    for (let deviceId = 0; deviceId < controllerCount; deviceId++) {
        const device = await client.getDeviceController(deviceId);
        const colors = Array(device.colors.length).fill({
            red: 0xff,
            green: 0x00,
            blue: 0x00,
        });

        console.log(`Setting the color of ${device.name}`);
        await client.updateLeds(deviceId, colors);
    }

    await client.disconnect();
}

start();

error

/home/makerio/Projects/node_modules/openrgb-sdk/src/client.js:50
        await this.socket?.end()
                          ^

SyntaxError: Unexpected token .
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/makerio/Projects/node_modules/openrgb-sdk/src/index.js:2:10)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
Mola19 commented 3 years ago

Which node version do you have? (Type node -v in the console)

makerio90 commented 3 years ago

v10.19.0

Mola19 commented 3 years ago

The package was only usable for node versions 14 or higher, but i just decided that it was not worth it and made the code compatible with lower versions. I would still strongly encourage you to update since javascript gained many features, that you might miss out on. If you update the package or download it again (now 0.4.3) it should work.