{"record":{"id":"a4be75131dd1e526","repo":"cube-js/cube","slug":"configuration-file-must-export-the-configuration-a","errorCode":null,"errorMessage":"Configuration file must export the configuration as default.","messagePattern":"Configuration file must export the configuration as default\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-server/src/server/container.ts","lineNumber":370,"sourceCode":"    });\n\n    return config as any;\n  }\n\n  protected async loadConfigurationFromFile(): Promise<CreateOptions> {\n    const file = await import(\n      path.join(process.cwd(), 'cube.js')\n    );\n\n    if (this.configuration.debug) {\n      console.log('Loaded js configuration file', file);\n    }\n\n    if (file.default) {\n      return file.default;\n    }\n\n    throw new Error(\n      'Configuration file must export the configuration as default.'\n    );\n  }\n\n  /**\n   * @param embedded Cube.js will start without https/ws/graceful shutdown + without timers\n   */\n  public async start(embedded: boolean = false) {\n    const makeInstance = async (override: boolean) => {\n      const userConfig = await this.lookupConfiguration(override);\n\n      const configuration = {\n        // By default graceful shutdown is disabled, but this value is needed for reboot\n        gracefulShutdown: getEnv('gracefulShutdown') || (process.env.NODE_ENV === 'production' ? 30 : 2),\n        ...userConfig,\n      };\n\n      const server = await this.runServerInstance(","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-server/src/server/container.ts#L352-L388","documentation":"Cube read the configuration file from disk (require of cube.js / dist config) and the module's export did not contain a `default` property holding CreateOptions. loadConfigurationFromFile only accepts `file.default`. Practically the config must be exported as default (ESM style or module.exports.default).","triggerScenarios":"A cube.js config using `module.exports = { ... }` without a default key, or named-only exports, being loaded by loadConfigurationFromFile via lookupConfiguration.","commonSituations":"Older Cube projects (pre-default-export era) upgrading the server package; copying config snippets using module.exports into a project whose loader expects default export; TypeScript files compiled without proper interop so default lands elsewhere.","solutions":["Export the config as default: `module.exports.default = { ... }` or `export default { ... }` in TS","Migrate legacy `module.exports = {...}` configs to the default-export form","Enable esModuleInterop in tsconfig if compiling TS config manually","Confirm which file lookupConfiguration is loading (cube.js vs dist/cube.js) and fix the right one"],"exampleFix":"// before\nmodule.exports = {\n  driverFactory: () => new PostgresDriver({}),\n};\n\n// after\nmodule.exports = {\n  default: {\n    driverFactory: () => new PostgresDriver({}),\n  },\n};\n// or in TS/ESM: export default { driverFactory: ... };","handlingStrategy":"validation","validationCode":"const configModule = require('./cube.js');\nif (!configModule.default) {\n  throw new Error('cube.js must export configuration as default: module.exports.default = {...}');\n}","typeGuard":"function hasDefaultExport(m: unknown): m is { default: Record<string, unknown> } {\n  return typeof m === 'object' && m !== null && 'default' in m;\n}","tryCatchPattern":"try {\n  await server.listen();\n} catch (e) {\n  if (e.message === 'Configuration file must export the configuration as default.') {\n    console.error('Convert module.exports = {...} to module.exports.default = {...} or export default');\n  }\n  throw e;\n}","preventionTips":["Migrate legacy cube.js configs to the default-export form","Grep the project for `module.exports =` in config files after upgrading Cube","Use TypeScript configs (which enforce export default) going forward","Run the server locally before deploying to catch config loading issues"],"tags":["configuration","default-export","esm-cjs"],"backgroundTag":"missing-default-export","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}