Search code examples
typescriptnestjstypeorm

NestJS: Cannot find module in dev mode


enter image description here

I have this error in development mode of an application with NestJS.

My configuration file is as follows:

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'],
};

I import into:

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

So far I couldn't identify the error of why it works in production and doesn't work in development mode to watch my modifications.


Solution

  • You could try this:

    For example when i make some file from the nestjs cli, there import his path like this:

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

    giving the error like you.

    enter image description here

    Then when i replace the path to find it manually:

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

    the error is fixed. enter image description here