Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

421
Vistas
Cannot add cli parameters to DataSourceOptions in TypeORM

In the typeORM documentation a cli parameter can be added to DataSourceOptions according to https://github.com/typeorm/typeorm/blob/master/docs/data-source-options.md. The example I saw on https://typeorm.io/using-cli looks was

{
    cli: {
        entitiesDir: "src/entity",
        subscribersDir: "src/subscriber",
        migrationsDir: "src/migration"
    }
}

I tried this in my code as follows:

let dataSource = new DataSource(
  {
        type: 'postgres',
        host: 'localhost',
        port: 5432,
        database: 'website',
        username: 'test',
        password: 'test',
        logging: true,
        synchronize: false,
        entities: [User, Posts],
        cli: {
            entitiesDir: "src/entity",
            subscribersDir: "src/subscriber",
            migrationsDir: "src/migration"
        }
  })

However I get the following error: Argument of type '{ type: "postgres"; host: string; port: number; database: string; username: string; password: string; logging: true; synchronize: false; entities: (typeof User | typeof Wallet)[]; cli: { entitiesDir: string; subscribersDir: string; migrationsDir: string; }; }' is not assignable to parameter of type 'DataSourceOptions'. Object literal may only specify known properties, and 'cli' does not exist in type 'PostgresConnectionOptions'.ts(2345)

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I had the same problem. To solve this issue, you can simply remove the cli key from the Datasource options and specify the path when creating a new migration

typeorm migration:create -n UrlMigration -d src/migrations 

-d option is used to specify the directory where your migration will be created

"scripts": {
  ...
  "typeorm": "typeorm-ts-node-commonjs -d ormconfig.ts"
}

NB : Replace ormconfig.ts with your datasource filename

refer to TypeORM CLI help

about 4 years ago · Juan Pablo Isaza Denunciar

0

TypeORM and TypeORM CLI not works perfectly after 0.3.0. I had the same problem, so I advice you to downgrade to version 0.2

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda