SyntaxError: Cannot use import statement outside a module

怎么办  还能怎么办  接着查  不要放弃

百度问题有时候百度一半  乱七八糟的答案 

我相信你

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

就可以了 

记得点赞哈  加油  我是小白  摸索了几天呢   谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值