getting build errors while using aws-iot-device-sdk in reactjs application
Asked Answered
B

1

6

I am trying to use aws-iot-device-sdk js sdk in our reactjs application. I am getting below errors..

ERROR in ./~/aws-iot-device-sdk/common/lib/tls-reader.js Module not found: Error: Cannot resolve module 'fs' in /Users/xxxxx/react/aws-iot/node_modules/aws-iot-device-sdk/common/lib @ ./~/aws-iot-device-sdk/common/lib/tls-reader.js 17:16-29

ERROR in ./~/aws-iot-device-sdk/device/lib/tls.js Module not found: Error: Cannot resolve module 'tls' in /Users/xxxx/react/aws-iot/node_modules/aws-iot-device-sdk/device/lib @ ./~/aws-iot-device-sdk/device/lib/tls.js 17:10-24

How to get rid of these errors?

Brouhaha answered 29/5, 2017 at 15:13 Comment(7)
github.com/josephsavona/valuable/issues/9Undergraduate
@Undergraduate I've already tried that but no luck. I am getting error like Uncaught TypeError: filesys.existsSync is not a functionBrouhaha
@Undergraduate Sorry, I am getting below error ERROR in ./~/aws-iot-device-sdk/~/mqtt/mqtt.js Module parse failed: /Users/xxxx/react/aws-iot/node_modules/aws-iot-device-sdk/node_modules/mqtt/mqtt.js Unexpected character '#' (1:0) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected character '#' (1:0)Brouhaha
The error message says you need appropriate loader, which means you lack some webpack loaderUndergraduate
Yeah, I understood it but we dont generally babelify node_modules, right? I think if we babelify node_modules/aws-iot-device-sdk/, it will resolve but are we supposed to do thisBrouhaha
That is true, did you try to removing the nodes_module folder and re-installing deps?Undergraduate
Yeah, that is the first thing I generally do when I got these type of issuesBrouhaha
V
0

It's an old question. However, with ReactJS applications, generally with browser-based frontend applications, you should use the AWS JavaScript SDK. The documentation for the aws-iot-device-sdk states

These SDKs are for use on your IoT device. If you're developing an IoT app for use on a mobile device, see the AWS Mobile SDKs. If you're developing an IoT app or server-side program, see the AWS SDKs.

Valerio answered 19/1, 2022 at 8:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.