Error:
[nodemon] starting node backend/server.js
Server started on PORT: 4000 i DEVELOPMENT mode.
D:\shop\node_modules\mongodb\lib\connection_string.js:289
throw new error_1.MongoParseError(${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported
);
^
MongoParseError: option usecreateindex is not supported at parseOptions (D:\shop\node_modules\mongodb\lib\connection_string.js:289:15) at new MongoClient (D:\shop\node_modules\mongodb\lib\mongo_client.js:62:63) at D:\shop\node_modules\mongoose\lib\connection.js:784:16 at new Promise () at NativeConnection.Connection.openUri (D:\shop\node_modules\mongoose\lib\connection.js:781:19) at D:\shop\node_modules\mongoose\lib\index.js:341:10 at D:\shop\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5 at new Promise () at promiseOrCallback (D:\shop\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10) at Mongoose._promiseOrCallback (D:\shop\node_modules\mongoose\lib\index.js:1141:10)
Node.js v17.4.0 [nodemon] app crashed - waiting for file changes before starting...
My code:
const connectDatabase = () => {
mongoose.connect(process.env.DB_LOCAL_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
}).then(con => {
console.log(`MongoDB Database connected with HOST: ${con.connection.host}`)
})
}
module.exports = connectDatabase```