使用webpack-hmr配置热加载后,与TypeOrmModule会产生冲突,无法读取entity文件配置,可以使用getMetadataArgsStorage引入即可。
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { getMetadataArgsStorage } from 'typeorm';
// The modules are loaded from here, hence importing the entities
import { AModule } from './a/a.module';
import { BModule } from './b/b.module';
@Module({
imports: [
AModule,
BModule,
TypeOrmModule.forRoot({
...,
entities: getMetadataArgsStorage().tables.map(tbl => tbl.target),
migrations: ...,
}),
]
})
export class AppModule {}
Nestjs使用webpack-hmr与TypeOrmModule冲突问题
https://blog.wangboweb.site/archives/nestjs-shi-yong-webpack-hmr-yu-typeormmodule-chong-tu-wen-ti
Comments