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

时间:2019-09-01 23:57:39

标签: typescript nestjs typeorm

enter image description here

在使用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 {}

到目前为止,我无法确定为什么它在生产中起作用而在开发模式下无法观察我的修改的错误。

1 个答案:

答案 0 :(得分:1)

您可以尝试以下方法:

例如,当我从nestjs cli创建一些文件时,在那里导入他的路径,如下所示:

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

给出与您一样的错误。

enter image description here

然后当我替换手动查找路径时:

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

该错误已修复。 enter image description here