怎么办 还能怎么办 接着查 不要放弃
百度问题有时候百度一半 乱七八糟的答案
我相信你
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Function.Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at tryToRequire (D:\git3\demo\src\util\ImportUtils.ts:21:17)
at importOrRequireFile (D:\git3\demo\src\util\ImportUtils.ts:35:25)
解决方法 :postgresql - 迁移文件中的 NestJS TypeORM 语法错误
更改了 typeormconfig.TS中
entities: [`${basePath}/entity/**/*{.ts,.js}`],
migrations: [`${basePath}/migration/**/*{.ts,.js}`],
改为
entities: ['dist/**/*.entity{.ts,.js}'],
migrations: ['dist/migration/*{.ts,.js}'],
[Nest] 15440 - 2023/12/15 10:02:21 LOG [NestFactory] Starting Nest application...
[Nest] 15440 - 2023/12/15 10:02:21 LOG [InstanceLoader] AppModule dependencies initialized +11ms
[Nest] 15440 - 2023/12/15 10:02:21 LOG [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 15440 - 2023/12/15 10:02:21 LOG [InstanceLoader] TypeOrmCoreModule dependencies initialized +37ms
[Nest] 15440 - 2023/12/15 10:02:21 LOG [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 15440 - 2023/12/15 10:02:21 LOG [InstanceLoader] UserModule dependencies initialized +1ms
[Nest] 15440 - 2023/12/15 10:02:21 LOG [RoutesResolver] UserController {/con}: +12ms
[Nest] 15440 - 2023/12/15 10:02:21 LOG [RouterExplorer] Mapped {/con/getAccountList, GET} route +3ms
[Nest] 15440 - 2023/12/15 10:02:21 LOG [NestApplication] Nest application successfully started +2ms
就可以了
记得点赞哈 加油 我是小白 摸索了几天呢 谢谢