未捕获的TypeError:filesys.existsSync不是函数 [英] Uncaught TypeError: filesys.existsSync is not a function
问题描述
当尝试使用适用于JavaScript的AWS IoT SDK初始化IOT设备时,出现错误
When trying to initialize IOT device using AWS IoT SDK for JavaScript, its giving error
TypeError:filesys.existsSync不是函数
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
});
tls-reader.js为何具有此未定义的功能?
How come tls-reader.js has this undefined function?
推荐答案
如果您尝试通过浏览器使用aws-iot-sdk,将无法正常工作.在您的示例中,您尝试使用路径访问证书,该路径是浏览器运行时不可用的功能.FileSystem是一个系统模块,浏览器不支持,但节点支持.但是,您可以使用浏览"解决此问题.有关更多信息,请参见 sdk文档.
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.
这篇关于未捕获的TypeError:filesys.existsSync不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!