I'm trying to set up a node project in typescript.
Two files causing errors :
node_modules/@types/mongoose/index.d.ts:79:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: DocumentDefinition, FilterQuery, UpdateQuery, NativeError, Mongoose, CastError, ConnectionOptions, Collection, Connection, disconnected, connected, connecting, disconnecting, uninitialized, Error, QueryCursor, VirtualType, Schema, SchemaTypeOpts, Subdocument, Array, DocumentArray, Buffer, ObjectIdConstructor, Decimal128, Map, Aggregate, SchemaType, Document, ModelUpdateOptions
79 declare module "mongoose" {
node_modules/mongoose/index.d.ts:1:1
1 declare module "mongoose" {
~~~~~~~
Conflicts are in this file.
node_modules/@types/mongoose/index.d.ts:226:14 - error TS2403: Subsequent variable declarations must have the same type. Variable 'SchemaTypes' must be of type 'typeof Types', but here has type 'typeof Types'.
226 export var SchemaTypes: typeof Schema.Types;
~~~~~~~~~~~
Mongoose includes TypeScript types since [email protected]
, so you can remove the package @types/mongoose
.
Source: https://developer.mongodb.com/community/forums/t/schema-error-while-running-backend-server-nestjs-angular/12440/3
I just had the same issue and fixed it by adding "skipLibCheck": true
to my tsconfig.json
. So I didn't have to downgrade Mongoose.
nevermind I downgraded mongoose by running 'npm i [email protected]', it worked
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