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

本文主要是介绍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 authenticationat E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\pool.js:581:63at 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 authenticationat E:\vscode\alibaixiu\code\alibaixiu\node_modules\mongodb-core\lib\connection\pool.js:581:63at 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)

这篇关于2021.12.19报错解决:UnhandledPromiseRejectionWarning: MongoError: command find requires authentication的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/406217

相关文章

MySQL中FIND_IN_SET函数与INSTR函数用法解析

《MySQL中FIND_IN_SET函数与INSTR函数用法解析》:本文主要介绍MySQL中FIND_IN_SET函数与INSTR函数用法解析,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一... 目录一、功能定义与语法1、FIND_IN_SET函数2、INSTR函数二、本质区别对比三、实际场景案例分

Pyserial设置缓冲区大小失败的问题解决

《Pyserial设置缓冲区大小失败的问题解决》本文主要介绍了Pyserial设置缓冲区大小失败的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录问题描述原因分析解决方案问题描述使用set_buffer_size()设置缓冲区大小后,buf

PyInstaller打包selenium-wire过程中常见问题和解决指南

《PyInstaller打包selenium-wire过程中常见问题和解决指南》常用的打包工具PyInstaller能将Python项目打包成单个可执行文件,但也会因为兼容性问题和路径管理而出现各种运... 目录前言1. 背景2. 可能遇到的问题概述3. PyInstaller 打包步骤及参数配置4. 依赖

解决SpringBoot启动报错:Failed to load property source from location 'classpath:/application.yml'

《解决SpringBoot启动报错:Failedtoloadpropertysourcefromlocationclasspath:/application.yml问题》这篇文章主要介绍... 目录在启动SpringBoot项目时报如下错误原因可能是1.yml中语法错误2.yml文件格式是GBK总结在启动S

idea maven编译报错Java heap space的解决方法

《ideamaven编译报错Javaheapspace的解决方法》这篇文章主要为大家详细介绍了ideamaven编译报错Javaheapspace的相关解决方法,文中的示例代码讲解详细,感兴趣的... 目录1.增加 Maven 编译的堆内存2. 增加 IntelliJ IDEA 的堆内存3. 优化 Mave

如何解决mmcv无法安装或安装之后报错问题

《如何解决mmcv无法安装或安装之后报错问题》:本文主要介绍如何解决mmcv无法安装或安装之后报错问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mmcv无法安装或安装之后报错问题1.当我们运行YOwww.chinasem.cnLO时遇到2.找到下图所示这里3.

浅谈配置MMCV环境,解决报错,版本不匹配问题

《浅谈配置MMCV环境,解决报错,版本不匹配问题》:本文主要介绍浅谈配置MMCV环境,解决报错,版本不匹配问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录配置MMCV环境,解决报错,版本不匹配错误示例正确示例总结配置MMCV环境,解决报错,版本不匹配在col

Feign Client超时时间设置不生效的解决方法

《FeignClient超时时间设置不生效的解决方法》这篇文章主要为大家详细介绍了FeignClient超时时间设置不生效的原因与解决方法,具有一定的的参考价值,希望对大家有一定的帮助... 在使用Feign Client时,可以通过两种方式来设置超时时间:1.针对整个Feign Client设置超时时间

Spring事务中@Transactional注解不生效的原因分析与解决

《Spring事务中@Transactional注解不生效的原因分析与解决》在Spring框架中,@Transactional注解是管理数据库事务的核心方式,本文将深入分析事务自调用的底层原理,解释为... 目录1. 引言2. 事务自调用问题重现2.1 示例代码2.2 问题现象3. 为什么事务自调用会失效3

mysql出现ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost‘ (10061)的解决方法

《mysql出现ERROR2003(HY000):Can‘tconnecttoMySQLserveron‘localhost‘(10061)的解决方法》本文主要介绍了mysql出现... 目录前言:第一步:第二步:第三步:总结:前言:当你想通过命令窗口想打开mysql时候发现提http://www.cpp