如何在 MongoDB 中删除此弃用警告以及为什么会发生这种情况?

Ay*_*ush 21 rest mongoose mongodb

我只是想创建一个 API 并在我的 app.js 文件中连接到它,但每次运行 app.js 时我都会收到此弃用警告。我已经检查了 mongoose 和 MongoDB 中的所有弃用警告,但我找不到任何与我匹配的警告。我得到的警告是,

(node:16864) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency

(Use node --trace-warnings ... to show where the warning was created)

(node:16864) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.

为什么我会收到此弃用警告以及如何将其删除?

小智 12

我猜这个警告出现在 mongoose 5.11.16 版本中。如果您想在错误得到修复之前避免看到它们,那么您可以选择 mongoose 版本 5.11.15。卸载 mongoose 5.11.16 并安装npm install mongoose@5.11.15