#Error: Cannot find module './index.js' with typeOrm-extension

1 messages · Page 1 of 1 (latest)

ornate kayak
#

package.json:

{
    "scripts": {
        "db:create": "ts-node ./node_modules/typeorm-extension/dist/cli/index.js db:create",
        "db:drop": "ts-node ./node_modules/typeorm-extension/dist/cli/index.js db:drop",
        "seed": "ts-node ./node_modules/typeorm-extension/dist/cli/index.js seed",
    },
    "dependencies": {
        "@nestjs/typeorm": "^10.0.0",
        "typeorm": "^0.3.17",
        "typeorm-extension": "^3.1.1",
    },
    "devDependencies": {
        "typescript": "^5.2.2"
    }
}
#

data-source.ts:

export const dataSourceOptions: DataSourceOptions = {
    type: 'postgres',
    host: process.env.DATABASE_HOST,
    port: parseInt(process.env.DATABASE_PORT),
    username: process.env.DATABASE_USER,
    password: process.env.DATABASE_PASSWORD,
    database: process.env.DATABASE_NAME,
    entities: [__dirname + '/../src/classes/**/**/entities/*.entity{.ts,.js}'],
    migrations: [__dirname + '/../db/migrations/*.js']
};

export const seederOptions: SeederOptions = {
    seeds: [
        'src/database/seeds/app.seeder{.ts,.js}',
        'src/database/seeds/users/*{.ts,.js}'
    ],
    factories: ['src/database/factories/**/*{.ts,.js}']
};

const dataSource = new DataSource({ ...dataSourceOptions, ...seederOptions });
export default dataSource;

I use seederOptions in app.module -> forRoot() and it works.
I've also tried with const option: DataSourceOptions & SeederOptions = {...} but nothing changes

#

My files :

backend
|db
||migrations
||data-source.ts
|src
||database
|||seeds
||||app.seeder.ts
||||other seeders
#

When I look in ./node_modules/typeorm-extension/dist/cli/index.js
there is a file index.d.ts but no index.ts