{"id":"91be01f7f1eb25b4","repo":"typeorm/typeorm","slug":"no-connection-options-were-found-in-any-orm-config","errorCode":null,"errorMessage":"No connection options were found in any orm configuration files.","messagePattern":"No connection options were found in any orm configuration files\\.","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"src/connection/ConnectionOptionsReader.ts","lineNumber":40,"sourceCode":"\n            /**\n             * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n             */\n            configName?: string\n        },\n    ) {}\n\n    // -------------------------------------------------------------------------\n    // Public Methods\n    // -------------------------------------------------------------------------\n\n    /**\n     * Returns all connection options read from the ormconfig.\n     */\n    async get(): Promise<DataSourceOptions[]> {\n        const options = await this.load()\n        if (!options)\n            throw new TypeORMError(\n                `No connection options were found in any orm configuration files.`,\n            )\n\n        return options\n    }\n\n    // -------------------------------------------------------------------------\n    // Protected Methods\n    // -------------------------------------------------------------------------\n\n    /**\n     * Loads all connection options from a configuration file.\n     *\n     * todo: get in count NODE_ENV somehow\n     */\n    protected async load(): Promise<DataSourceOptions[] | undefined> {\n        let connectionOptions:\n            DataSourceOptions | DataSourceOptions[] | undefined = undefined","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/typeorm/typeorm/blob/04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96/src/connection/ConnectionOptionsReader.ts#L22-L58","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: no ormconfig file, code calls new ConnectionOptionsReader().get()\n\n// after (ormconfig.ts at project root)\nimport { DataSourceOptions } from 'typeorm'\nexport const config: DataSourceOptions = { type:'postgres', host:'localhost', username:'root', password:'password', database:'typeorm' }","handlingStrategy":"validation","validationCode":"const reader = new ConnectionOptionsReader({ root: process.cwd(), configName: 'ormconfig' })\nconst exists = await reader.all().catch(() => false)\nif (!exists) throw new Error('ormconfig missing')","typeGuard":"const ormconfigPresent = async (root = process.cwd()): Promise<boolean> => {\n  const exts = ['js','mjs','cjs','ts','mts','cts','json']\n  return exts.some(e => fs.existsSync(`${root}/ormconfig.${e}`))\n}","tryCatchPattern":"try {\n  options = await reader.get()\n} catch (err) {\n  if (/No connection options were found/.test(err.message)) { /* fall back to inline options */ }\n  throw err\n}","preventionTips":["Ship an ormconfig.* file or pass DataSourceOptions explicitly.","Watch the console for the 'Could not load ormconfig file' warning that precedes this error."],"tags":["configuration","ormconfig","connection-options","filesystem"],"analyzedSha":"04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96","analyzedAt":"2026-08-03T18:27:32.281Z","schemaVersion":2}