当我运行"nodemon server "时,出现"MongoParseError: options poolsize, usenewurlparse are not supported"错误。
以下是设置mongodb连接的代码:
import app from "./server.js"
import mongodb from "mongodb"
import dotenv from "dotenv"
dotenv.config()
const MongoClient = mongodb.MongoClient
const port = process.env.PORT || 8000
MongoClient.connect(
process.env.RESTREVIEWS_DB_URI,
{
poolSize: 50,
wtimeout: 2500,
useNewUrlParse: true,
}
)
.catch(err => {
console.error(err.stack)
process.exit(1)
})
.then(async client => {
app.listen(port, () => {
console.log(`listening on port ${port}`)
})
})