关于nodejs 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.

const mongoose = require(‘mongoose‘)

mongoose.connect("mongodb://localhost:27017/study", {useNewUrlParser:true}, function(err){

  if(err){

    console.log(‘Connection Error:‘ + err)

  }else{

    console.log(‘Connection success!‘) }

})

原文地址:https://www.cnblogs.com/TomAndJerry/p/9363951.html

时间: 2024-10-08 18:35:13

关于nodejs 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 报错代码 (node:10256)(node:13604)(node:13604) DeprecationWarning: Mongoose: findOneAndUpdate() { useUnifiedTopology: true } { useNewUrlParser: true } to MongoClient.connect.

起因 在MongoDB Node.js驱动程序中有几个弃用,Mongoose提供了解决这些弃用警告的选项 原因是因为:findOneAndUpdate()内部会使用findAndModify驱动,驱动即将被废弃,所以弹出警告!附上官方解释:Mongoose v5.5.8: Deprecation Warnings 被替换的还有下面几个: 将update()替换为updateOne(),updateMany(),replaceOne() 将remove()替换为deleteOne()或delete

DeprecationWarning: current URL string parser is deprecated解决方法

我最近在使用mongoDB的时候,发现了这个警告语句,纳闷了,按照官方文档的教程去连接数据库还能出错,也是醉了. 后来尝试去阅读相关资料,发现只是需要将{ useNewUrlParser: true }传入到connect方法中即可: MongoClient.connect(url, (err, client) => {}) 改为 MongoClient.connect(url, { useNewUrlParser: true }, (err, client) => {}) 就不会显示那烦人的

node----DeprecationWarning: current URL string parser is deprecated和Port 3000 is already in use的问题

首先,安装了express和supervisor: 在package.json中: "scripts": { "start": "supervisor ./bin/www" }, 项目根目录下的命令窗口中运行:npm start 但结果却出现以下情况: DeprecationWarning: current URL string parser is deprecated, and will be removed in a future versi

SimpleCursorAdapter(Context, int, Cursor, String[], int[]) is deprecated???

ListAdapter bookAdapter = new SimpleCursorAdapter(this,R.layout.booklist,cursor,from,to); 提示:The constructor SimpleCursorAdapter(Context, int, Cursor, String[], int[]) is deprecated API 16给出的解析:@Deprecated public SimpleCursorAdapter(Context context,

大熊君大话NodeJS之------(Url,QueryString,Path)模块

一,开篇分析 这篇文章把这三个模块拿来一起说,原因是它们各自的篇幅都不是很长,其次是它们之间存在着依赖关系,所以依次介绍并且实例分析.废话不多说了,请看下面文档: (1),"Url模块" 来个小栗子: 1 var url = require('url'); 2 var queryUrl = "http://localhost:8888/bb?name=bigbear&memo=helloworld" ; 3 console.log(typeof url.pa

Getting SharePoint objects (spweb, splist, splistitem) from url string

You basically get anything in the object model with one full url: 1 //here is the site for the url 2 using (SPSite site = new SPSite("http://basesmcdev2/sites/tester1/tester4/A0805051340564172608.txt")) 3 { 4 //here is the web for the url 5 usin

Nodejs模块之URL模块

URL模块: url模块有3个可以调用的方法, url.parse()是用来解析一个URL地址的,将它解析为一个对象. url.format()是将一个URL对象格式化成一个URL字符串. url.resolve()也是用来解析的,但传入两个参数,能把两个参数拼接成浏览器可以识别的格式. url.parse('http://www.baidu.com') 解析的情况如下: Protocol:'http'.指定的是底层使用的协议. Slashes:'true',是说是否有协议的双斜线 Host,是

nodejs获取当前url和url参数值

//需要使用的模块 http url当前url http://localhost:8888/select?aa=001&bb=002var http = require('http');var URL = require('url');http.createServer(function(req, res){ var arg = url.parse(req.url).query; //方法一arg => aa=001&bb=002 var arg = url.parse(req.ur

Nodejs express 获取url参数,post参数的三种方式

Js代码  : express获取参数有三种方法:官网实例: Checks route params (req.params), ex: /user/:id Checks query string params (req.query), ex: ?id=12 Checks urlencoded body params (req.body), ex: id= 1.例如:127.0.0.1:3000/index,这种情况下,我们为了得到index,我们可以通过使用req.params得到,通过这种方