aws / aws-iot-device-sdk-js

SDK for connecting to AWS IoT from a device using JavaScript/Node.js
Apache License 2.0
964 stars 384 forks source link

V2.* doesn't work with node 4.2.6 #425

Closed wiewiur667 closed 9 months ago

wiewiur667 commented 10 months ago

Describe the bug

I'm trying to run latest version of package using node 4.2.6(only available on target device)

When trying to run examples using nvm it fails, issue is that mqtt-packet is using classes and mqtt dependencies are using Buffer.from which is not available in that node version.

Downgrading mqtt to version 1.11.2 and websocket-stream to ^3.1.0 used in V1.* solves problem

Expected Behavior

Be able to use package in node 4.2.6

Current Behavior

root:/mnt/f/src/aws-iot-device-sdk-js# nvm exec 4.2 node ./examples/device-example.js Running node v4.2.6 (npm v2.14.12) /mnt/f/src/aws-iot-device-sdk-js/node_modules/mqtt-packet/parser.js:7 class Parser extends EventEmitter { ^^^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:374:25) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at Object. (/mnt/f/src/aws-iot-device-sdk-js/node_modules/mqtt-packet/mqtt.js:1:80) at Module._compile (module.js:410:26) at Object.Module._extensions..js (module.js:417:10)

Reproduction Steps

clone git repository npm install nvm exec 4.2 node ./examples/device-example.js

Possible Solution

Downgrade packages

Additional Information/Context

No response

SDK version used

2.2.13

Environment details (OS name and version, etc.)

Ubuntu WSL 22.04 - nvm with node 4.2.6

jmklix commented 10 months ago

Is there a specific reason why you can't update to a more recent version of node? Version 4.2.6 was last supported in 2018, so I would not recommended trying to use it. We can't guarantee that this sdk will work with such an old version of node. Please update your node version to a more recent one and let me know if you have any problems with the sdk.

wiewiur667 commented 10 months ago

Hi,

I can't update it as it's the only version Samsung SSSP4 SoC supports. I don't mind using v1.* as it works, but it's confusing that your package.json says that you support node 4.0.0.

Maybe you could bump up the engines version to avoid confusion in future.

jmklix commented 9 months ago

I've tested this sdk with the older versions of node and 8.17 is the oldest release that works. I've also created a PR to update our documentation. Please let me know if this works for you and/or you have any other questions about this sdk.

github-actions[bot] commented 9 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

bretambrose commented 9 months ago

One other thing: I imagine if you look back in versions, you will eventually hit one that can be used with node 4. I'm pretty sure the version bump came about due to the need to update dependencies from a CVE perspective. In general, almost all of the CVE updates we've done don't represent an actual vulnerability while using the SDK, so if you're comfortable using an older version that will throw up a lot of npm audit warnings, that might be the right direction.