I encountered an issue when attempting to include the entity.ts in the project
Here is the content of ts file:
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"
@Entity('Usuario')
export class UsuarioIdentity {
@PrimaryGeneratedColumn() id: number;
@Column('text') username: string;
@Column('text') password: string;
}
This is my ormconfig:
{
"type": "mysql",
"host": "localhost",
"port": "3306",
"username": "root",
"password": "password",
"database": "blogdb",
"synchronize": true,
"logging": true,
"entities": ["src/Entidades/*.entity{.ts,.js}", "dist/Entidades/*.entity{.ts,.js}"]
}
The Error message displayed is as follows:
[Nest] 21736 - 2021-06-03 3:04:09 PM [NestFactory] Starting Nest application... [Nest] 21736 - 2021-06-03 3:04:09 PM [InstanceLoader] TypeOrmModule dependencies initialized >+148ms [Nest] 21736 - 2021-06-03 3:04:09 PM [InstanceLoader] AppModule dependencies initialized +2ms [Nest] 21736 - 2021-06-03 3:04:09 PM [TypeOrmModule] Unable to connect to the database. Retrying (1)... +21ms import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; ^ SyntaxError: Unexpected token { at Module._compile (internal/modules/cjs/loader.js:721:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at E:\Proyectos_ejemplos\React- NestJS\Back2\node_modules\typeorm\util\DirectoryExportedClassesLoader.js:42:39 at Array.map (<anonymous>) at Object.importClassesFromDirectories (E:\Proyectos_ejemplos\React- NestJS\Back2\node_modules\typeorm\util\DirectoryExportedClassesLoader.js:42:10)
If I comment out the entity or delete it, everything seems to work fine. I am currently using NestJS version 7.6.15 and typeorm version 0.2.34
Please provide assistance if possible :D
UPDATE
Below is my tsconfig file where I suspect the issue might be related to the outDir setting
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
}
}