JavaScript User Authentication With Express and Mongo User Registration Setting Up Mongoose and a Mongo Database

Daniel Baker
Daniel Baker
15,351 Points

(node:7288) DeprecationWarning:

When following along I received this error:

(node:7288) 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.

I googled it and made this change:

// mongodb connection
mongoose.connect("mongodb://localhost:27017/bookworm", { useNewUrlParser: true });

Error went away, hope this helps others.

Thanks! I was just about to look this up as well.

2 Answers

Ryan Doran
Ryan Doran
7,813 Points

The new documentation requires another addition as well: {useUnifiedTopology: true}

mongoose.connect("mongodb://localhost:27017/bookworm", { 
    useNewUrlParser: true, 
    useUnifiedTopology: true 

Good catch while going through this videos is also a good idea to have the latest documentation of the packages in

there you can see the solution directly from the documentation.