RKD*_*RKD 10 javascript orm node.js typeorm nestjs
我正在从 Udemy https://www.udemy.com/course/nestjs-zero-to-hero学习 NestJS 课程。
而且我遇到了一个奇怪的问题,我尝试了很多东西,但似乎没有任何效果。这是我拥有的问题和完整代码。
我得到的错误
我的 ORM 配置文件:
最后我在 tasks.module.ts 文件中导入配置文件

面临这个问题的人已经用不同的修复方法解决了这个问题,
我已经尝试了所有可以通过 Internet 获得的可能解决方案,但无法解决此问题。现在已经好几天了,我正在寻找堆栈溢出的帮手或救星。
同时,我将尝试查看更多可能有帮助的可能性,但如果您遇到此问题,请告诉我可能的解决方案。
Hak*_*kan 15
entities: [__dirname + '/../**/*.entity.ts']
Run Code Online (Sandbox Code Playgroud)
到
entities: [__dirname + '/../**/*.entity.js']
Run Code Online (Sandbox Code Playgroud)
在typeorm.config.ts
它对我有效
小智 11
在NestJS 中.js,边添加边.ts为我工作
typeorm.config.ts
前
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
export const TypeORMConfig: TypeOrmModuleOptions = {
type: 'postgres',
url: process.env.DATABASE_URL,
synchronize: true,
entities: [__dirname + '/../**/*.entity.ts'],
migrationsTableName: 'Migrations_History',
};
Run Code Online (Sandbox Code Playgroud)
后
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
export const TypeORMConfig: TypeOrmModuleOptions = {
type: 'postgres',
url: process.env.DATABASE_URL,
synchronize: true,
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
migrationsTableName: 'Migrations_History',
};
Run Code Online (Sandbox Code Playgroud)
小智 9
我也遇到过同样的问题。在尝试了此处提到的所有其他对我不起作用的解决方案后,我通过添加以下选项修改了typeorm.config.ts文件:
autoLoadEntities: true,
Run Code Online (Sandbox Code Playgroud)
这已经解决了这个问题。
| 归档时间: |
|
| 查看次数: |
4409 次 |
| 最近记录: |