[Solved] mongoose Error: Error: `useCreateIndex` is an invalid option.

Error message

if (VALID_OPTIONS.indexOf(key) === -1) throw new Error(`\`${key}\` is an invalid option.`);
                                         ^
Error: `useCreateIndex` is an invalid option.
at Mongoose.set ... 

Solution:

Mongoose 6 no longer needs useCreateIndex, please remove it when upgrading.

Read More: