【问题标题】:DeprecationWarning: current Server Discovery and Monitoring engine is deprecated弃用警告:不推荐使用当前的服务器发现和监控引擎
【发布时间】:2020-04-26 09:08:12
【问题描述】:

我知道,我知道问题已经解决了,但还没有。

我在跑步:

mongoose 5.8.4 和 nodemon 2.0.2 以防万一。

const mongoose = require('mongoose');
const config = require('config');
const db = config.get('mongoURI');

const connectDB = () => {
  mongoose
    .connect(db, {
      useNewUrlParser: true,
      useCreateIndex: true,
      useFindAndModify: false
      // useUnifiedTopology: true
    })
    .then(() => console.log('MongoDB connected!'))
    .catch(err => {
      console.error(err.msg);
      process.exit(1);
    });
};

module.exports = connectDB;

当我使用useUnifiedTopology: true 在大约 30 秒后运行服务器时,会显示一条消息:

[nodemon] 应用程序崩溃 - 启动前等待文件更改...

关于如何修复此错误的任何想法?

【问题讨论】:

  • 如果您不使用useUnifiedTopology 并等待相同的时间,应用程序不会崩溃吗?
  • 确实,或者,确实。

标签: javascript node.js mongodb


【解决方案1】:

在 Atlas 上创建了一个新集群,一切正常。无论如何,谢谢,伙计们。

【讨论】:

    猜你喜欢
    • 2020-02-22
    • 2020-05-12
    • 2020-08-25
    • 2020-01-13
    • 2022-01-04
    • 1970-01-01
    • 2021-12-16
    • 2012-05-10
    • 1970-01-01
    相关资源
    最近更新 更多