Current URL string parser is deprecated

Yusuf Delvi picture Yusuf Delvi · Jul 4, 2018 · Viewed 19.6k times · Source

when I run the code by "node app.js" command this error is showing

(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.

Answer

Nyambati Thomas picture Nyambati Thomas · Jul 5, 2018

You need to pass { useNewUrlParser: true } option to mongoose.connect() method. Your code should look similar to the snippet below.

mongoose.connect('mongodb://user:[email protected]:27017/dbname', { useNewUrlParser: true })