问题
When trying to initialize IOT device using AWS IoT SDK for JavaScript, its giving error
TypeError: filesys.existsSync is not a function
var device = AWSIoTData.device({
keyPath: "././assets/certificate/xx",
certPath: "././assets/certificate/xx",
caPath: "././assets/certificate/xx",
clientId: "xx",
host: "xx",
region: "xx",
port: 8883,
debug: true
});
How come tls-reader.js has this undefined function?
回答1:
If your trying to work with aws-iot-sdk with browser this will not work as expected. In your example your trying to access the certificates using path which is a functionality not available on browser runtime. FileSystem is a system module and it's not supported by a browser but supported by node. However you can use to "browserify" get this resolved. Refer to the sdk documentation for more information.
来源:https://stackoverflow.com/questions/55390719/uncaught-typeerror-filesys-existssync-is-not-a-function