1

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.

4
  • check if paths imports have the prefix "src/..." if is there replace it for manually location "../../..." Commented Sep 2, 2019 at 0:14
  • import { Entity, PrimaryGeneratedColumn, Column } from '../../../node_modules/typeorm'; I tried to add, but it still didn't work ... Commented Sep 2, 2019 at 0:23
  • not for node_modules, try with yours services,controllers,modules,entities files Commented Sep 2, 2019 at 0:25
  • could you provide your tsconfig.json file content please ? Commented Sep 2, 2019 at 10:14

1 Answer 1

8

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

Sign up to request clarification or add additional context in comments.

1 Comment

Many thanks for the reply. But, I wonder if there is any way to change this reference? To not have to be manually importing ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.