首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NPM UnhandledPromiseRejectionWarning

NPM UnhandledPromiseRejectionWarning
EN

Stack Overflow用户
提问于 2021-12-16 00:42:59
回答 1查看 136关注 0票数 1

我在虚拟机和AWS上设置了一个20.04Ubuntu服务器,以运行不再由开发人员托管的uno。(https://github.com/Exium1/UnoBot)我一直在遵循别人关于如何设置它的指南(https://github.com/DaanWet/UnoBot/blob/master/documentation/Install.md),但是当我启动它时,它失败了。

我得到以下错误:

代码语言:javascript
复制
(node:14998) UnhandledPromiseRejectionWarning: DiscordHTTPError: 401 Unauthorized on GET /api/v9/gateway/bot
    at RequestHandler.request (/home/ubuntu/UnoBot/node_modules/eris-sharder/node_modules/eris/lib/rest/RequestHandler.js:75:15)
    at Client.getBotGateway (/home/ubuntu/UnoBot/node_modules/eris-sharder/node_modules/eris/lib/Client.js:2135:36)
    at ClusterManager.calculateShards (/home/ubuntu/UnoBot/node_modules/eris-sharder/src/sharding/clustermanager.js:507:38)
    at process.nextTick (/home/ubuntu/UnoBot/node_modules/eris-sharder/src/sharding/clustermanager.js:179:41)
    at process._tickCallback (internal/process/next_tick.js:61:11)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
(node:14998) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by
 rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14998) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js pro
cess with a non-zero exit code.

有人能帮忙解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2021-12-16 14:58:36

为了解决已记录的UnhandledPromiseRejectionWarning警告,您可以通过在代码中添加以下内容来修复它:

代码语言:javascript
复制
process.on("unhandledRejection", console.error);

这将更清楚地记录错误,并将防止您的控制台被这些警告填满。

至于@mmenschig所说的话,它们确实是正确的。确保将正确的令牌传递到<Client>.login()中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70372020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档