The `useMongoClient` option is no longer necessary in Mongoose 5.x, Please remove it

Asked

Viewed 706 times

1

I tried to connect to the bank using these settings;

'use strict'

var mongoose = require('mongoose');

mongoose.Promise = global.Promise;
mongoose.connect('mongodb://127.0.0.1:27017/ep', { useMongoClient: true })
        .then(() => {
                console.log('conexão realizada com sucesso')
        })
        .catch(err => console.log(err));

Trying to run the test application generated this error;

 npm start

> [email protected] start C:\layout resposive\API\ep
> nodemon index.js

[nodemon] 1.17.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
WARNING: The `useMongoClient` option is no longer necessary in mongoose 5.x, please remove it.
    at handleUseMongoClient (C:\layout resposive\API\ep\node_modules\mongoose\lib\connection.js:506:17)
    at NativeConnection.Connection.openUri (C:\layout resposive\API\ep\node_modules\mongoose\lib\connection.js:407:7)
    at Mongoose.connect (C:\layout resposive\API\ep\node_modules\mongoose\lib\index.js:208:15)
    at Object.<anonymous> (C:\layout resposive\API\ep\index.js:6:10)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
    at startup (internal/bootstrap/node.js:201:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
conexão realizada com sucesso

Someone has a suggestion?

1 answer

3


This was one of the changes from version 4 to 5, in the migration manual talk about it. Basically: from version 5 this option has been removed, the value is always true, so it is now a mistake to pass this configuration option.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.