NestJS:在开发模式下找不到模块

NestJS: Cannot find module in dev mode

我在使用 NestJS 的应用程序开发模式中遇到此错误。

我的配置文件如下:

export const ORM_CONFIG: TypeOrmModuleOptions = {
  keepConnectionAlive: true,
  type: 'postgres',
  host: 'localhost',
  port: 5432,
  username: 'postgres',
  password: 'postgres',
  database: 'aimbra_education',
  schema: 'security',
  synchronize: true,
  entities: [
   --Entities
  ],
  // migrations: [__dirname + '/migration/**/*.ts'],
  // subscribers: [__dirname + '/subscriber/**/*.ts'],
};

我导入到:

@Module({
  imports: [
    TypeOrmModule.forRoot(ORM_CONFIG),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

到目前为止我无法确定为什么它在生产模式下工作而在开发模式下不工作以观看我的修改的错误。

你可以试试这个:

例如,当我从 nestjs cli 制作一些文件时,会像这样导入他的路径:

import { UsersService } from 'src/modules/users/users.service';

和你一样报错

然后我替换路径的时候手动找:

import { UsersService } from './users.service';

错误已修复。