Nestjs 错误:无法在模块外部使用导入语句

Nestjs 错误:无法在模块外部使用导入语句,nestjs,typeorm,Nestjs,Typeorm,在配置迁移后执行命令npm run start:dev时,我从“typeorm”接收到错误导入{MigrationInterface,QueryRunner};语法错误:无法在模块外部使用import语句我通过将migrations文件夹移动到src中来修复它。ormconfig.tsconst-config:ConnectionOptions={type:'mysql',host:process.env.DATABASE\u host,port:parseInt(process.env.DAT

在配置迁移后执行命令
npm run start:dev
时,我从“typeorm”接收到错误导入{MigrationInterface,QueryRunner};语法错误:无法在模块外部使用import语句

我通过将migrations文件夹移动到src中来修复它。

ormconfig.ts
const-config:ConnectionOptions={type:'mysql',host:process.env.DATABASE\u host,port:parseInt(process.env.DATABASE\u port),用户名:process.env.DATABASE_用户,密码:process.env.DATABASE_密码,数据库:process.env.DATABASE_名称,实体:[\uuu dirname+'/**/**.entity{.ts、.js}'],同步:false,日志记录:true,迁移运行:true,迁移:[\uu dirname+'/../migrations/**/**.ts、.js}'],cli:{migrationsDir:'./migrations',}}export=config;
app.module.ts
ConfigModule.forRoot(),TypeOrmModule.forRoot({…ormconfig,keepConnectionAlive:true,autoLoadEntities:true}),
package.json
“typeorm”:“ts node-r tsconfig path/register./node_modules/typeorm/cli.js--config./src/ormconfig.ts”,“迁移:生成”:“npm运行类型表单迁移:生成--n”,“迁移:运行”:“npm运行类型表单迁移:运行”,“迁移:还原”:“npm运行类型表单迁移:还原”“
migrations work corrective如果我删除了迁移文件,那么命令
npm run start:dev
工作正常。