Node.js warns that useNewUrlParser or useUnifiedTopology has no effect
useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major versionShort answer
Since Node.js Driver 4.0.0 the driver always uses the new URL parser and unified topology, so passing useNewUrlParser or useUnifiedTopology does nothing and prints a warning. Delete both options from MongoClient or mongoose.connect. Driver 7.0 removed them from the options type, so leftover code can also fail type checks.
Fix it fast
1Find out which cause you have
Find every place the two options are passed, including config files and copied tutorial snippets.
grep -rn "useNewUrlParser\|useUnifiedTopology" --include=*.js --include=*.ts --include=*.mjs .2Match what you see, then jump to its fix
- 1
The warning prints once at start-up and your code calls new MongoClient(uri, { useNewUrlParser: true, ... }).The options are passed to new MongoClientFix - 2
The warning appears when you call mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true }).The options are passed to mongoose.connectFix - 3
TypeScript no longer lists useNewUrlParser and useUnifiedTopology in MongoClientOptions after the upgrade.You upgraded to Node.js driver 7 and the options are gone from the typesFix
- 1
What does the error look like?
useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major versionuseUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
Cause 1 of 3
The options are passed to new MongoClient
1Check
The driver's own option table marks both options as having no effect since 4.0.0, and its source emits the warning when either is given.
grep -rn "new MongoClient" --include=*.js --include=*.ts .2Fix
Remove both options. A plain client needs only the connection string.
const client = new MongoClient(uri);
await client.connect();3Verify
Start the app again; the warning no longer prints.
node app.jsConfirmed by raw.githubusercontent.com
Cause 2 of 3
The options are passed to mongoose.connect
1Check
Mongoose passes its options to the driver. The Mongoose 6 guide calls these options no longer supported, says they are treated as enabled, and asks you to remove them.
npm ls mongoose mongodb2Fix
Remove the options from mongoose.connect.
await mongoose.connect(uri);3Verify
Restart the app and check the console.
node app.jsConfirmed by mongoosejs.com
Cause 3 of 3
You upgraded to Node.js driver 7 and the options are gone from the types
1Check
The driver's upgrade guide lists MongoClientOptions.useNewUrlParser and MongoClientOptions.useUnifiedTopology among the options removed in version 7.0.
npm ls mongodb2Fix
Remove the options from your code; there is no replacement because the behaviour is always on.
const client = new MongoClient(uri, { maxPoolSize: 20 });3Verify
Run your TypeScript build or tests again.
npm testConfirmed by mongodb.com
How do I stop it coming back?
- Copy connection code from the current driver docs, not from older tutorials.
- Read the upgrade guide before moving to a new major version of the mongodb package.
- Keep connection options in one module so cleanup happens in one place.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Mongoose warns that the Server Discovery and Monitoring engine is deprecated
current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version.
The warning comes from Mongoose 5, which still connects with the legacy topology engine.
3 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fix