【问题标题】:I get this error when I try to run this code: MongoParseError: options poolsize, usenewurlparse are not supported尝试运行此代码时出现此错误: MongoParseError: options poolsize, usenewurlparse is not supported
【发布时间】:2021-09-16 00:21:15
【问题描述】:

当我尝试运行此代码时会显示此消息。我正在在线学习教程,并且是 MERN 堆栈的新手。

import app from "./server.js";
import mongodb from "mongodb";
import dotenv from "dotenv";

dotenv.config(); /* configure dotenv */
const MongoClient =
  mongodb.MongoClient; /* get access to MongoClient from MongoDB */
const port = process.env.PORT || 8000; //connect port

//Connect to MongoDB
MongoClient.connect(process.env.RESTREVIEWS_DB_URI, {
  poolSize: 50,
  wtimeout: 2500,
  useNewUrlParser: true,
})
  .catch((err) => {
    console.error(err.stack);
    process.exit(1);
  })
  .then(async (client) => {
    //app.listen is used to start our web server, after connecting to the DB
    app.listen(port, () => {
      //we're listening at the port
      console.log(`listening on port ${port}`);
    });
  });

【问题讨论】:

    标签: javascript mongodb mern


    【解决方案1】:

    删除poolSize: 50useNewUrlParser: true 怎么样,因为错误告诉您它们不再受支持?

    【讨论】:

    • 如果我想将用户限制设置为 50 怎么办?我交叉检查了,这是用于设置该限制的关键。与 useNewUrlParser 相同(我刚刚得知他们已弃用此功能)
    • 使用maxPoolSize(和useUnifiedTopology=true)? FYI
    猜你喜欢
    • 2021-09-25
    • 2022-08-21
    • 2019-01-26
    • 2021-12-24
    • 1970-01-01
    • 2022-11-07
    • 2019-10-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多