MongoParseError: Load balancer mode requires driver version 4+
Asked Answered
A

2

7

I have built a loopback 3 app with mongodb, worked perfectly on local and vps. But I wanted to opt for the SaaS (mongodb.com and heroku.com) and now I am facing an error:

    /node_modules/loopback-connector-mongodb/node_modules/mongodb/lib/utils.js:698
          throw error;
          ^

MongoParseError: Load balancer mode requires driver version 4+

I have updated the loopback-connector-mongodb, installed mongodb 4.4.0 through npm and made sure of the compatibility.

P.S: since I am using the shared plan from mongodb.com, I cannot turn off the load balancer.

Aphotic answered 26/2, 2022 at 8:57 Comment(0)
H
4

If you want to use serverless Mongo. Mongoose version should be higher than 6. To fix the above issue, update Mongoose:

npm install [email protected]
Had answered 26/8, 2022 at 8:11 Comment(1)
Here is a link from the MongoDB forums regarding the same topic - mongodb.com/community/forums/t/…. Also, it mentions the compatibility table of Serverless - mongodb.com/docs/atlas/reference/….Jonjona
D
-3

Update the MongoDB driver in your Node.js application to version 4 or higher. You can do this using npm (Node Package Manager):

npm install mongodb@4

This command will install the latest version of the MongoDB Node.js driver (version 4 at the time of writing).

Update Mongoose (if necessary): If you are using Mongoose ORM, ensure that your version of Mongoose is compatible with the MongoDB driver version you've installed. Generally, the latest versions of Mongoose should be compatible with recent versions of the MongoDB driver.

npm install mongoose@latest
Dietsche answered 11/7 at 6:38 Comment(2)
You are providing outdated information. Likely, you are copying and pasting some outdated source. Also, this does not offer fundamentally new information than the other highly voted answer.Upheld
ya information is outdated but not copied.Dietsche

© 2022 - 2024 — McMap. All rights reserved.