javascript - Mongo 错误:UnhandledPromiseRejectionWarning:MongoError:没有经过身份验证的用户
问题描述
为什么我会收到此错误。我在使用 macbook pro。在一个项目中工作,该项目有一个 node.js api 和 mongodb 数据库,其中 mongoose 作为 ODM 和一个快速服务器。我多次看到这个错误,不知道为什么会这样。有人有想法吗?希望得到一些帮助。
我试过的:卸载Mongodb,重新安装。擦除项目文件并重新克隆它们。擦拭我的 Mac(这有效,但当再次出现此错误时必须再次执行此操作)。也没有任何身份验证,所以它不应该要求它。
我还检查并确保我的代码没有未处理的承诺,我已经确认。
MongoDB connected
listening on http://localhost:4000
(node:57471) UnhandledPromiseRejectionWarning: MongoError: there are no users authenticated
at Connection.<anonymous> (/Users/chirag/Desktop/labs/shopping-cart-be/node_modules/mongodb/lib/core/connection/pool.js:460:61)
at Connection.emit (events.js:315:20)
at processMessage (/Users/chirag/Desktop/labs/shopping-cart-be/node_modules/mongodb/lib/core/connection/connection.js:368:10)
at Socket.<anonymous> (/Users/chirag/Desktop/labs/shopping-cart-be/node_modules/mongodb/lib/core/connection/connection.js:537:15)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
(node:57471) 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:57471) [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.
解决方案
推荐阅读
- javascript - Javascript构造函数创建与先前创建的对象具有相同值的新对象
- command - GNU APL 行编辑器(∇-editor)支持哪些编辑命令?
- javascript - 基于特定数据的 Firebase 实时数据库规则
- python - startfile" 文件路径应该是字符串、字节或 os.Pathlike,而不是列表
- spring-boot - 无法在 tcp://xxx.xxx.xx.xxx:2375 连接到 Docker 守护程序。docker 守护进程是否正在运行?
- python - Python 错误不可散列类型:带有熊猫 iloc 的“列表”
- c++ - 媒体基础:使用 Direct3D 11 的自定义拓扑
- javascript - 当文本区域中存在文本时更改表单提交按钮的(样式) - Jade / Pug
- java - 用普通文本字体替换字符串
- java - 无法@Mock Autowired 对象