TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. - getting this error in db url

Viewed 2105

This is my string

 const uri = 'mongodb+srv://ad:xyz@abc-2xyzs.mongodb.net/test?retryWrites=true&w=majority'

 const client = new MongoClient(uri);

I'm getting the error

TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
    at validateString (internal/validators.js:117:11)
.
.
.
code: 'ERR_INVALID_ARG_TYPE'

I have tried to parse url. But nothing seems to be working

2 Answers

I just updated my socket.io and express version and this error was resolved

You have to upgrade your dependencies. Run npm update --save

Related