2021.12.19报错解决:UnhandledPromiseRejectionWarning: MongoError: command find requires authentication

解决思路:

1.查看报错原因,翻译后了解原因

UnhandledPromiseRejectionWarning: MongoError: command find requires authentication

2.通过百度查询查看相似问题,通过博客:https://blog.csdn.net/w_hx10/article/details/109538770
知道是因为之前设置过mongodb的权限,所以访问时需要添加一些设置
3.按照博客进行修改,问题解决
总结:认真查看别人写的博客,要耐下性子去看别人的博客(之前看过几遍这个人的博客,但是忽视了这个博客)
完整报错代码:

PS E:\vscode\alibaixiu\code\alibaixiu> node .\app.js
(node:18100) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:18100) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:18100) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:18100) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
服务器启动成功
数据库连接成功
(node:18100) UnhandledPromiseRejectionWarning: MongoError: command find requires authentication
    at E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\pool.js:581:63
    at authenticateStragglers (E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\pool.js:504:16)
    at Connection.messageHandler (E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\pool.js:540:5)
    at emitMessageHandler (E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\connection.js:310:10)
    at Socket.<anonymous> (E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\connection.js:453:17)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:290:12)
    at readableAddChunk (internal/streams/readable.js:265:9)
    at Socket.Readable.push (internal/streams/readable.js:204:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(node:18100) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:18100) [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.
(node:18100) UnhandledPromiseRejectionWarning: MongoError: command find requires authentication
    at E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\pool.js:581:63
    at authenticateStragglers (E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\pool.js:504:16)
    at Connection.messageHandler (E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\pool.js:540:5)
    at emitMessageHandler (E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\connection.js:310:10)
    at Socket.<anonymous> (E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\connection.js:453:17)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:290:12)
    at readableAddChunk (internal/streams/readable.js:265:9)
    at Socket.Readable.push (internal/streams/readable.js:204:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(node:18100) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

intoSunshine

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值