I use MongoDB and NestJs. When I connect the entity module to another module it throws error. How can I fix it?
Error: Cannot find module 'src/entities/user/account.module'
Require stack:
- /Users/programming/newList-back/src/components/auth/auth.module.ts
- /Users/programming/newList-back/src/app.module.ts
- /Users/programming/newList-back/src/main.ts
at Function.<anonymous> (internal/modules/cjs/loader.js:889:15)
at Function._resolveFilename (/Users/programming/newList-back/node_modules/@cspotcode/source-map-support/source-map-support.js:679:30)
at Function._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (/Users/programming/newList-back/src/components/auth/auth.module.ts:2:1)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Module._compile (/Users/programming/newList-back/node_modules/ts-node/src/index.ts:1455:23)
at internal/modules/cjs/loader.js:1101:10
at Object..ts (/Users/programming/newList-back/node_modules/ts-node/src/index.ts:1458:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/programming/newList-back/src/components/auth/auth.module.ts',
'/Users/programming/newList-back/src/app.module.ts',
'/Users/programming/newList-back/src/main.ts'
]
}
Entity module
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { MongooseModule } from '@nestjs/mongoose';
import { AccountDAO } from './account.dao';
import { userAccountModelDefinition } from './account.schema';
import { AccountService } from './account.service';
@Module({
providers: [AccountService, AccountDAO],
exports: [AccountService],
imports: [ConfigModule, MongooseModule.forFeature([userAccountModelDefinition], 'users')],
})
export class AccountModule {}
CodePudding user response:
Like recommended in comments, changing path from src/entities/user/account.module
on ../../entities/user/account.module
has helped.