不建议使用当前的URL字符串解析器 [英] Current URL string parser is deprecated
本文介绍了不建议使用当前的URL字符串解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我通过"node app.js"命令运行代码时,此错误正在显示
when I run the code by "node app.js" command this error is showing
(节点:2509)DeprecationWarning:不建议使用当前URL字符串解析器,并将在以后的版本中将其删除.要使用新的解析器,请将选项{useNewUrlParser:true}传递给MongoClient.connect.
(node:2509) 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.
推荐答案
您需要将{ useNewUrlParser: true }
选项传递给mongoose.connect()方法.您的代码应与以下代码段相似.
You need to pass { useNewUrlParser: true }
option to mongoose.connect() method. Your code should look similar to the snippet below.
mongoose.connect('mongodb://user:pw@host1.com:27017/dbname', { useNewUrlParser: true })
这篇关于不建议使用当前的URL字符串解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文