Typeormを導入してよくわからないエラーが発生しました。
解決策:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import {Module} from '@nestjs/common'; import {AppController} from './app.controller'; import {AppService} from './app.service'; import {ItemService} from './services/item.service'; import {ItemController} from './controllers/item.controller'; import {TypeOrmModule} from '@nestjs/typeorm'; import {Item} from './entities/item.entity'; @Module({ imports: [ TypeOrmModule.forFeature([Item]), TypeOrmModule.forRoot({ type: 'sqlite', database: 'db/typeorm-test', synchronize: true, entities: [Item]})], // <= これも大丈夫 //entities: ['dist/**/*.entity.js']})], <= これも大丈夫 //entities: ['src/entities/*.entity.ts' ]})], <= これだとエラー出る controllers: [AppController, ItemController], providers: [AppService, ItemService], }) export class AppModule { } |
参考記事
TypeORM Entity in NESTJS – Cannot use import statement outside a module