I installed @nestjs/mongoose with following npm command:
npm i --save @nestjs/mongoose mongoose
But when I try to lauch the app, I get following errors:
node_modules/@nestjs/mongoose/dist/decorators/prop.decorator.d.ts:2:44 - error TS2694: Namespace '"mongoose"' has no exported member 'SchemaTypeOpts'.
export declare type PropOptions = mongoose.SchemaTypeOpts<any> | mongoose.Schema | mongoose.SchemaType;
~~~~~~~~~~~~~~
node_modules/@nestjs/mongoose/dist/factories/schema.factory.d.ts:4:60 - error TS2315: Type 'Schema' is not generic.
static createForClass<T = any>(target: Type<unknown>): mongoose.Schema<T>;
~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/mongoose/dist/interfaces/mongoose-options.interface.d.ts:3:10 - error TS2305: Module '"mongoose"' has no exported member 'ConnectionOptions'.
import { ConnectionOptions } from 'mongoose';
~~~~~~~~~~~~~~~~~
Found 3 error(s).
Any help would be highly appreciated.
Revert your mongoose
install down to 5.10.x
. The latest version of mongoose
came out with their own set of types, which ended up breaking a lot of things: Reference Issue
The best combination that worked for me is the following.
"@nestjs/mongoose": "^7.0.4",
"mongoose": "^5.10.19",
"@types/mongoose": "^5.10.3", //dev-dependency
As of 19 Dec 2020, any version later than that did NOT work for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With