Installing MongoDB/Mongoose - I can't get around useUnifiedTopology not supported

I’m doing the installing MongoDB/Mongoose section
and I keep getting

the options [useUnifiedTopology] is not supported
(node:563) Warning: Accessing non-existent property ‘count’ of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
(node:563) Warning: Accessing non-existent property ‘findOne’ of module exports inside circular dependency
(node:563) Warning: Accessing non-existent property ‘remove’ of module exports inside circular dependency
(node:563) Warning: Accessing non-existent property ‘updateOne’ of module exports inside circular dependency
Your app is listening on port 3000
(node:563) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘split’ of null
at parseSrvConnectionString (/home/runner/boilerplate-mongomongoose/node_modules/mongodb-core/lib/uri_parser.js:40:23)
at parseConnectionString (/home/runner/boilerplate-mongomongoose/node_modules/mongodb-core/lib/uri_parser.js:421:12)
at connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/node_modules/mongodb/lib/operations/mongo_client_ops.js:180:3)
at connectOp (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/node_modules/mongodb/lib/operations/mongo_client_ops.js:284:3)
at executeOperation (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/node_modules/mongodb/lib/utils.js:420:24)
at MongoClient.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js:168:10)
at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:521:12
at new Promise ()
at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:518:19)
at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:270:15)
at Object. (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
(node:563) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line options | Node.js v17.3.0 Documentation). (rejection id: 3)
(node:563) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Safari/605.1.15

Challenge: Install and Set Up Mongoose

Link to the challenge:

1 Like

which version did you install? did you use the mongodb@~3.6.0 and mongoose@~5.4.0

and do you have in the connect the useUnifiedTopology option set to true? I have similar problem in my personal project recently, but setting this to true helped me.

mongoose.connect(<Your URI>, { useNewUrlParser: true, useUnifiedTopology: true });

hey yes I used the versions as you stated and set the useUnifiedTopology to true as well. here are some snippets of my code.

“name”: “fcc-mongo-mongoose-challenges”,
“version”: “0.0.1”,
“description”: “A boilerplate project”,
“main”: “server.js”,
“scripts”: {
“start”: “node server.js”
“dependencies”: {
“body-parser”: “^1.15.2”,
“dotenv”: “^8.2.0”,
“express”: “^4.12.4”,
“mongodb”: “^3.6.0”,
“mongoose”: “^5.4.0”
“repository”: {
“type”: “git”,
“url”: “GitHub - freeCodeCamp/boilerplate-mongomongoose: A boilerplate for the freeCodeCamp curriculum.
“keywords”: [
“license”: “MIT”


const mongoose=require(‘mongoose’);
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });

hm… weird… but try to install the version with ~ instead of ^. because both might result in different version being installed.
~ install the approximately same version, so same minor version, only newer patch… so insead of 3.6.0 it might install 3.6.3
^ install compatible version, so same major version… so instead of 3.6.0 it might install 3.9.3
you can see in package-lock file what version is really installed or use terminal to determine it.

this worked for me about 2 days ago:

"dependencies": {
        "body-parser": "^1.15.2",
        "dotenv": "^8.2.0",
        "express": "^4.12.4",
        "mongodb": "~3.6.0",
        "mongoose": "~5.4.0"

Didn’t change anything unfortunately.

Do you have Replit you can post the link to?

Thanks all. If anyone else solved it and can share tips, I’d appreciate it.
It says mongoose is not connected to a database.

it is weird… if I would run it locally, I would just remove the node modules and install everything again… .maybe try to delete this project and make it again - this time use ~ when in the package.json and install it.
also make sure that you have correctly set up the DB itself… you need to allow the access from everwhere and the user you are using in the connection url needs to have the priviledge to access the DB (see the tutorial suggested by the challenge: MongoDB Atlas Tutorial – How to Get Started)

value in the replit’s padlock does not need any quote.

1 Like

OMG! THANK YOU! My error is MONGO_URI = being accidentally quoted twice in the secrets tab. OMG! :pray:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.