标签:node code alibaixiu 19 2021.12 js vscode connection 报错
解决思路:
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)
标签:node,code,alibaixiu,19,2021.12,js,vscode,connection,报错 来源: https://blog.csdn.net/shaochen2015821426/article/details/122025028
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。