{"record":{"id":"c90232e83290b1ab","repo":"gatsbyjs/gatsby","slug":"10126","errorCode":"10126","errorMessage":"${context.path}/${context.configName} cannot export a function.\n\nA ${context.configName} exported as a function can only be used as a theme and not run directly.\nIf you are trying to run a theme directly, use the theme in an example site or starter instead and run that site to test.\nIf you are in the root gatsby-config for your site, change the export to be an object and not a function as functions\nare not supported in the root gatsby-config.","messagePattern":"(.+?)/(.+?) cannot export a function\\.\n\nA (.+?) exported as a function can only be used as a theme and not run directly\\.\nIf you are trying to run a theme directly, use the theme in an example site or starter instead and run that site to test\\.\nIf you are in the root gatsby-config for your site, change the export to be an object and not a function as functions\nare not supported in the root gatsby-config\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/bootstrap/load-config/index.ts","lineNumber":29,"sourceCode":"\nexport async function loadConfig({\n  siteDirectory,\n  processFlags = false,\n}: {\n  siteDirectory: string\n  processFlags?: boolean\n  program?: IProgram\n}): Promise<IGatsbyConfig> {\n  // Try opening the site's gatsby-config.js file.\n  const { configModule, configFilePath } = await getConfigFile(\n    siteDirectory,\n    `gatsby-config`\n  )\n  let config = preferDefault(configModule)\n\n  // The root config cannot be exported as a function, only theme configs\n  if (typeof config === `function`) {\n    reporter.panic({\n      id: `10126`,\n      context: {\n        configName: `gatsby-config`,\n        siteDirectory,\n      },\n    })\n  }\n\n  if (processFlags) {\n    // Setup flags\n    const {\n      enabledConfigFlags,\n      unknownFlagMessage,\n      unfitFlagMessage,\n      message,\n    } = handleFlags(availableFlags, config?.flags ?? {})\n\n    if (unknownFlagMessage !== ``) {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/bootstrap/load-config/index.ts#L11-L47","documentation":"Error \"${context.path}/${context.configName} cannot export a function.\n\nA ${context.configName} exported as a function can only be used as a theme and not run directly.\nIf you are trying to run a theme directly, use the theme in an example site or starter instead and run that site to test.\nIf you are in the root gatsby-config for your site, change the export to be an object and not a function as functions\nare not supported in the root gatsby-config.\" thrown in gatsbyjs/gatsby.","triggerScenarios":"Thrown at packages/gatsby/src/bootstrap/load-config/index.ts:29 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["In the root gatsby-config, export a plain object instead of a function","If developing a theme, run it through an example site or starter instead of directly"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e85d62f1779e353eaac1753211629a26d123e26c","analyzedAt":"2026-08-26T17:50:09.662Z","contentChangedAt":"2026-08-26T17:50:09.662Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}