Closed mortezasabihi closed 1 year ago
When I import this package like this:
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import aggregatePaginate from 'mongoose-aggregate-paginate-v2'; @Schema({ timestamps: true, }) export class User { @Prop({ required: true, unique: true }) email: string; @Prop({ required: true }) password: string; } export const UserSchema = SchemaFactory.createForClass(User); UserSchema.plugin(aggregatePaginate);
I got this error:
But when I change import like this:
// eslint-disable-next-line @typescript-eslint/no-var-requires const aggregatePaginate = require('mongoose-aggregate-paginate-v2');
error solved.
What's the problem?
this is my tsconfig:
{ "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "target": "es2017", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "skipLibCheck": true, "strictNullChecks": false, "noImplicitAny": false, "strictBindCallApply": false, "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false } }
@mortezasabihi Sorry the TS version is not managed in this repository.
@mortezasabihi This works for me:
import * as aggregatePaginate from 'mongoose-aggregate-paginate-v2';
When I import this package like this:
I got this error:![image](https://user-images.githubusercontent.com/35567646/148759814-88e05d80-8506-4cee-bb3a-165628e8a820.png)
But when I change import like this:
error solved.
What's the problem?
this is my tsconfig: