Error: No connection options were found in any orm configuration files.
See original GitHub issueBug Report
Current behavior
Getting an error that says [ExceptionHandler] No connection options were found in any orm configuration files.
when I try running my NestJS project using the Repository pattern with typeorm and a custom config
Input Code
import { createConnection, Connection } from 'typeorm'
import { DATABASE_CONNECTION } from '../constants'
import * as config from './ormconfig'
export const databaseProviders = [
{
provide: DATABASE_CONNECTION,
useFactory(): Promise<Connection> {
return createConnection(config)
}
}
]
Custom Configuration:
import { join } from 'path'
import { ConnectionOptions } from 'typeorm'
const config = {
host: 'localhost',
user: process.env.SQL_USER,
password: process.env.SQL_PASSWORD,
database: process.env.SQL_DATABASE,
}
const connectionOptions: ConnectionOptions = {
type: 'postgres',
host: config.host,
port: 5432,
username: config.user || 'postgres',
password: config.password || 'postgres',
database: config.database || 'my_database',
entities: [
join(__dirname, '../models/*{.ts,.js}'),
],
// We are using migrations, synchronize should be set to false.
synchronize: false,
dropSchema: false,
// Run migrations automatically,
// you can disable this if you prefer running migration manually.
migrationsRun: true,
logging: true,
migrations: [
join(__dirname, 'migrations/*{.ts,.js}')
],
cli: {
migrationsDir: './migrations'
}
}
export = connectionOptions
Expected behavior
Be able to run nest start
with my custom orm configuration
Possible Solution
It works executing ts-node -r tsconfig-paths/register src/main.ts
instead, but I want to execute other scripts like nest start --watch
and nest start --debug --watch
Environment
Nest version: 7.2.0
For Tooling issues:
- Node version: v10.15.3
- Platform: Mac
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
No connection options were found in any orm configuration ...
With these settings , I was already connected to the database with the oracledb. I generate project with this typeorm init --name MyProject...
Read more >No connection options were found in any orm configuration ...
You need to log in to use this function. Qiita can be used more conveniently after logging in. You can also use this...
Read more >Create Migration Error - Questions - n8n community
When i try to create migration files i got “Cannot use import statement ... No connection options were found in any orm configuration...
Read more >No Connection Options Were Found In Any Orm Configuration ...
Getting an error that says [ExceptionHandler] No connection options were found in any orm configuration files. when I try running my NestJS project...
Read more >Connecting TypeScript backend in EC2 to PostgreSQL RDS
js migration:run Error during migration run: TypeORMError: No connection options were found in any orm configuration files. at new TypeORMError (/home/ec2-user/ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank @jdnichollsc ,
For other peoples, I summary the solution of you as below.
ormconfig.ts
app.module.ts
, We reuse this config asPlease, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.