src/contact/contact.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ContactController } from './contact.controller';
import { Contact } from './contact.entity';
import { ContactRepository } from './contact.repo';
import { ContactService } from './contact.service';
@Module({
imports: [
TypeOrmModule.forFeature([
Contact,
]),
],
controllers: [ContactController],
providers: [ContactService, ContactRepository],
})
export class ContactModule {}
src/app.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { getMetadataArgsStorage } from 'typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ContactModule } from './contact/contact.module';
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'sqlite',
database: 'db',
entities: getMetadataArgsStorage().tables.map(tbl => tbl.target),
synchronize: true,
}),
ContactModule
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
npm new start:dev
Give this kind of error where I try to find possibly every solution on the internet but what mistake I’m doing I don’t know, I got an error like.
nest -v (8.1.6)
ERROR [ExceptionHandler] Nest can't resolve dependencies of the TypeOrmCoreModule (TypeOrmModuleOptions, ?). Please make sure that the argument ModuleRef at index [1] is available in the TypeOrmCoreModule context.
Potential solutions:
- If ModuleRef is a provider, is it part of the current TypeOrmCoreModule?
- If ModuleRef is exported from a separate @Module, is that module imported within TypeOrmCoreModule?
@Module({
imports: [ /* the Module containing ModuleRef */ ]
})