typeorm/typeorm · error · TypeORMError
No connection options were found in any orm configuration fi
Error message
No connection options were found in any orm configuration files.
What it means
Thrown by ConnectionOptionsReader.get when load() returns undefined, meaning no ormconfig file was found in any supported format (js/mjs/cjs/ts/mts/cts/json) at the base path, or the file existed but evaluated to a falsy value. The reader searches for a file named ormconfig.<ext> under the root (default cwd).
Source
Thrown at src/connection/ConnectionOptionsReader.ts:40
/**
* Filename of the ormconfig configuration. By default its equal to "ormconfig".
*/
configName?: string
},
) {}
// -------------------------------------------------------------------------
// Public Methods
// -------------------------------------------------------------------------
/**
* Returns all connection options read from the ormconfig.
*/
async get(): Promise<DataSourceOptions[]> {
const options = await this.load()
if (!options)
throw new TypeORMError(
`No connection options were found in any orm configuration files.`,
)
return options
}
// -------------------------------------------------------------------------
// Protected Methods
// -------------------------------------------------------------------------
/**
* Loads all connection options from a configuration file.
*
* todo: get in count NODE_ENV somehow
*/
protected async load(): Promise<DataSourceOptions[] | undefined> {
let connectionOptions:
DataSourceOptions | DataSourceOptions[] | undefined = undefinedView on GitHub (pinned to 04ff4daedc)
Solutions
- Create an ormconfig.{ts,js,json,...} file at the project root exporting DataSourceOptions.
- If you pass DataSourceOptions directly in code, avoid code paths that call ConnectionOptionsReader (or pass options explicitly).
- Check the console for the 'Could not load ormconfig file' warning that precedes this error to find the real load failure.
- Verify the root/configName you pass to ConnectionOptionsReader resolves to an existing file.
Example fix
// before: no ormconfig file, code calls new ConnectionOptionsReader().get()
// after (ormconfig.ts at project root)
import { DataSourceOptions } from 'typeorm'
export const config: DataSourceOptions = { type:'postgres', host:'localhost', username:'root', password:'password', database:'typeorm' } Defensive patterns
Strategy: validation
Validate before calling
const reader = new ConnectionOptionsReader({ root: process.cwd(), configName: 'ormconfig' })
const exists = await reader.all().catch(() => false)
if (!exists) throw new Error('ormconfig missing') Type guard
const ormconfigPresent = async (root = process.cwd()): Promise<boolean> => {
const exts = ['js','mjs','cjs','ts','mts','cts','json']
return exts.some(e => fs.existsSync(`${root}/ormconfig.${e}`))
} Try / catch
try {
options = await reader.get()
} catch (err) {
if (/No connection options were found/.test(err.message)) { /* fall back to inline options */ }
throw err
} Prevention
- Ship an ormconfig.* file or pass DataSourceOptions explicitly.
- Watch the console for the 'Could not load ormconfig file' warning that precedes this error.
When it happens
Trigger: Calling new ConnectionOptionsReader().get() (used by the CLI and by helpers that fall back to ormconfig) when there is no ormconfig.* file, when the file failed to load (load logs a warning and yields undefined), or when a custom configName/root does not match an existing file.
Common situations: Migrating to explicit DataSourceOptions in code but still invoking a code path that reads ormconfig; wrong configName; running the CLI from a directory without ormconfig; ormconfig file has a syntax/runtime error (load swallows it into a warning); env-specific config not present.
Related errors
- Unable to open file: "${dataSourceFilePath}". ${err.message}
- Option "${optionName}" is not set in your connection options
- Cannot read connection options in a browser context.
- This option/function is not supported in the browser environ
- This option/function is not supported in the browser environ
AI-assisted analysis of typeorm/typeorm@04ff4daedc (2026-08-03).
Data as JSON: /data/errors/91be01f7f1eb25b4.json.
Report an issue: GitHub.