美文网首页
DeprecationWarning: current URL

DeprecationWarning: current URL

作者: chxuu | 来源:发表于2020-10-29 09:07 被阅读0次

    问题

    1. node连接Mongoose时抛出了两个DeprecationWarning(弃用警告):
    (node:61084) 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.
    // 弃用警告:当前的URL字符串解析器已弃用,并且在将来的版本中会移除该功能。要用新的解析器,需要在调用MongoClient.connect是传参:{ useNewUrlParser: true }
    
    (node:61084) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
    // 弃用警告:当前的Server Discovery和Monitoring engine已弃用,并且在将来的版本中会移除该功能。要用新的Server Discover和Monitoring engine,需要在调用MongoClient.connect是传参:{ useUnifiedTopology: true }
    

    解决

    - MongoClient.connect(yourUrl)
    + MongoClient.connect(yourUrl, { useNewUrlParser: true, useUnifiedTopology: true })
    

    相关文章

      网友评论

          本文标题:DeprecationWarning: current URL

          本文链接:https://www.haomeiwen.com/subject/xfxkvktx.html