我一直在尝试使用 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.
这是什么意思? 这是否意味着它有效?
最佳答案
这意味着您运行的 Promises 之一被拒绝 - 这意味着它没有解析值,而是因错误而拒绝。
更具体地说,我们可以看到问题出在Error: Error: Opening/dev/ttyUSB0: Unknown error code 3
。我最好的猜测是您的程序无权进入该目录(USB),因此被拒绝并出现该错误。
为了防止拒绝,请在 .then
之后添加 catch
来处理错误。
了解有关 promise 的更多信息 here .
关于javascript - Node.js 未处理的PromiseRejectionWarning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48953750/