I was creating Nest.js project and faced some problems with it. I assume the problem lies within profile.entity.ts file since if I remove that file then all works ok. So, I have several files app.module.ts file:
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { typeOrmConfig } from './config/typeorm.config';
import { ProfileModule } from './profile/profile.module';
@Module({
imports: [TypeOrmModule.forRoot(typeOrmConfig), ProfileModule],
controllers: [],
providers: [],
})
export class AppModule {}
profile.entity.ts
import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from "typeorm";
@Entity()
export class Profile extends BaseEntity{
@PrimaryGeneratedColumn()
id: number;
@Column()
fullName: string;
@Column()
company: string;
@Column()
position: string;
@Column()
dateOfBirth: Date;
@Column()
phoneNumber: string;
@Column()
additionalPhoneNumber: string;
@Column()
email: string;
@Column()
additionalEmail: string;
@Column()
website: string;
@Column()
additionalWebsite: string;
@Column()
facebook: string;
@Column()
instagram: string;
@Column()
telegram: string;
@Column()
whatsapp: string;
@Column()
vk: string;
@Column()
tikTok: string;
@Column()
linkedIn: string;
@Column()
youTube: string;
@Column()
skype: string;
@Column()
modeDetails: string;
}
profile.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ProfileController } from './profile.controller';
import { ProfileRepository } from './profile.repository';
import { ProfileService } from './profile.service';
@Module({
imports:[TypeOrmModule.forFeature([ProfileRepository])],
controllers: [ProfileController],
providers: [ProfileService]
})
export class ProfileModule {}
profile.repository.ts
import { Profile } from './profile.entity';
import { EntityRepository, Repository } from 'typeorm';
@EntityRepository(Profile)
export class ProfileRepository extends Repository<Profile> {}
typeorm.config.ts
import { TypeOrmModuleOptions } from "@nestjs/typeorm";
export const typeOrmConfig:TypeOrmModuleOptions={
type:'postgres',
host:'localhost',
port:5432,
username:'postgres',
password:'M',
database: 'profileManagement',
entities:[__dirname + '/../**/*.entity.ts'],
synchronize:true
}
Please help I cannot find the exact place where I did wrong
question from:
https://stackoverflow.com/questions/65879765/exceptionhandler-no-metadata-for-profile-was-found-in-nest-js 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…