I am getting the below error for useNewUrlParser, useUnifiedTopology, useCreateIndex:
No overload matches this call.
Overload 1 of 3, '(uri: string, callback: CallbackWithoutResult): void', gave the following error.
Argument of type '{ useNewUrlParser: boolean; useUnifiedTopology: boolean; useCreateIndex: boolean; }' is not assignable to parameter of type 'CallbackWithoutResult'.
Object literal may only specify known properties, and 'useNewUrlParser' does not exist in type 'CallbackWithoutResult'.
Overload 2 of 3, '(uri: string, options?: ConnectOptions | undefined): Promise<typeof import("mongoose")>', gave the following error.
Argument of type '{ useNewUrlParser: boolean; useUnifiedTopology: boolean; useCreateIndex: boolean; }' is not assignable to parameter of type 'ConnectOptions'.
Object literal may only specify known properties, and 'useNewUrlParser' does not exist in type 'ConnectOptions'.
Index.ts
import express from 'express'
import { errorHandler } from './middleware/error-handler';
import router from './router'
import mongoose from 'mongoose'
const app = express()
app.use(express.json())
app.use('/api/users', router)
app.use(errorHandler)
const start = async () => {
try {
await mongoose.connect("mongodb://auth-mongo-srv:27017/auth", {
useNewUrlParser: true, // error here
useUnifiedTopology: true,
useCreateIndex: true,
});
console.log("Connected to MongoDb");
} catch (err) {
console.error(err);
}
};
const PORT = 3000
app.listen(PORT, () => {
console.log("working on port ",PORT)
})
start()
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
I have mongoose 6.02 installed in package.json and if it is of any help, I am getting mongo from dockerhub and running in a cluster pod.
Any help or suggestion is appreciated.