我一直在尝试使用Node.js对这个机器人汽车进行编程,但是在我运行这个程序后,它给了我这个错误。
您的环境已设置为使用Node.js 8.9.4 (x64)和npm。
C:\Users\john>node 4wd.js
http://localhost:3030
(node:8660) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error: Opening /dev/ttyUSB0: Unknown error code 3
(node:8660) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.这是什么意思?这是否意味着它起作用了?
发布于 2018-02-24 02:03:16
这意味着您运行的一个Promises被拒绝了-这意味着它不是解析一个值,而是返回一个错误。
更具体地说,我们可以看到这就是Error: Error: Opening /dev/ttyUSB0: Unknown error code 3的问题所在。我最好的猜测是,您的程序没有进入该目录( USB)的权限,因此被拒绝,并返回该错误。
为了防止被拒绝,请在.then之后添加一个catch来处理错误。
了解有关promises here的更多信息。
https://stackoverflow.com/questions/48953750
复制相似问题