'How setup ormconfig.js file using Typeorm?

I'm having problems after transpiling my application built with typescript.
When I try to access any one resource of my app it threw the following exception: EntityMetadataNotFoundError: No metadata for "Entity" was found. Where "Entity" is the name of the entity used in my resource.
See below one gist link with my ormconfig.js and more pieces of information about this problem. https://gist.github.com/filipevl/4004d8e5c39180456c8be769790ca80b

See anyway my ormconfig and entity code.

.env

DATABASE_URL=jdbc:mysql://root:@localhost:3306/collegato?reconnect=true
TYPEORM_ENTITIES=dist/entities/*.js
TYPEORM_MIGRATIONS=dist/migrations/.js

ormconfig.js

module.exports = {
    type: "mysql",
    url: process.env.DATABASE_URL,
    entities: [process.env.TYPEORM_ENTITIES],
    migrations: [process.env.TYPEORM_MIGRATIONS],
    cli: {
        migrationsDir: ["src/database/migrations/"],
        entitiesDir: "src/entities/",
    },
};

Users.ts

import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Unique } from "typeorm";

@Entity("Users")
export default class User {
    @PrimaryGeneratedColumn("increment")
    @Unique(["id"])
    readonly id: number;

    @Column()
    name: string;

    @Column()
    @Unique(["email"])
    email: string;

    @Column()
    password: string;

    @Column()
    permission: number;

    @CreateDateColumn()
    readonly created_at: Date;

    @UpdateDateColumn()
    updated_at: Date;
}

Since now thanks for helping me!

Note: I think this problem is not in the entity files because locally the app works well. I've already tried to exchange my ormconfig.js to .env, .ts, .json and the problem persist.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source