gpt4 book ai didi

node.js - 连接 MongoDB 时出现 Mistic 问题

转载 作者:太空宇宙 更新时间:2023-11-04 00:07:15 25 4
gpt4 key购买 nike

我已经在“Udemy”上学习了一些类(class)大约两周,直到今天我没有遇到任何问题。我制作了一个配置文件,添加了一个验证,然后当我运行服务器时,我遇到了这样的问题:

(node:9140) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

各位,你们有什么想法可以解决这个问题吗?我陷入困境,需要你的帮助。

我以这种方式连接到我的数据库:

mongoose
.connect(db)
.then(() => console.log("MongoDB connected"))
.catch(err => console.log(err));

我还尝试了 StackOverflow 其他主题的一些推荐: enter image description here

我的代码:

const db = require("./config/keys").mongoURI;

//连接MongoDb

mongoose
.connect(
db,
{ useNewUrlParser: true }
)
.then(() => console.log("MongoDB connected"))
.catch(err => console.log(err));

由于我的版本低于4,所以我使用了第二种方法,但仍然存在问题: enter image description here

两周以来一直有效。所有版本的node.js和mongodb: enter image description here

我的依赖项: enter image description here

最佳答案

弃用警告不是问题,它只是对 future 版本的警告(将来需要解决)。

据我从您发布的图片中可以看出,您的问题具体在于文件 users.js 上第 83 行的语句 res.strtus

关于node.js - 连接 MongoDB 时出现 Mistic 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51693445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com