Error: No connection options were found in any orm configuration files
From the picture you posted, you misplaced the ormconfig.json
in ./src directory which path maybe your_project/src/ormconfig.json
.Please move it to root directory of project(path: your_project/ormconfig.json
) will work out!
Hello I had the same error for one day, but I had to explicitly show the path of the config fileThis was my current typeorm
package.json
script command
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js"
i changed it to
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js --config src/config/postgres.config.ts"
not how I explicitly set the path of the config file that I am using, no matter which extension you are using, either .js
, .ts
, or .json
here is the example of my config file
// postgres.config.tsimport { TypeOrmModuleOptions } from '@nestjs/typeorm';export const pgConfig: TypeOrmModuleOptions = { type: 'postgres', host: process.env.POSTGRES_HOST, port: parseInt(<string>process.env.POSTGRES_PORT), username: process.env.POSTGRES_USER, password: process.env.POSTGRES_PASSWORD, database: process.env.POSTGRES_DATABASE, entities: ['dist/src/modules/**/entities/*.entity.js'], synchronize: true, migrations: ['dist/src/db/migrations.js'], cli: { migrationsDir: 'src/db/migrations' },};
Hope it gonna help
You can try use the following instead
npx typeorm migration:create -n migrationName