{"record":{"id":"ca8a958e63d7aa7f","repo":"vercel/turborepo","slug":"unable-to-load-generators","errorCode":null,"errorMessage":"Unable to load generators","messagePattern":"Unable to load generators","errorType":"exception","errorClass":"GeneratorError","httpStatus":null,"severity":"error","filePath":"packages/turbo-gen/src/utils/plop.ts","lineNumber":357,"sourceCode":"\nexport async function runCustomGenerator({\n  project,\n  generator,\n  bypassArgs,\n  configPath\n}: {\n  project: Project;\n  generator: Generator;\n  bypassArgs?: Array<string>;\n  configPath?: string;\n}): Promise<void> {\n  const resolvedConfigPath = configPath ?? generator.configPath;\n  const destBasePath = configPath ?? generator.destBasePath;\n\n  const plop = await createPlopFromConfig(resolvedConfigPath, destBasePath);\n\n  if (!plop) {\n    throw new GeneratorError(\"Unable to load generators\", {\n      type: \"plop_unable_to_load_config\"\n    });\n  }\n\n  let gen: PlopGenerator | undefined;\n  try {\n    gen = plop.getGenerator(generator.name) as PlopGenerator | undefined;\n  } catch {\n    // plop throws when generator not found\n  }\n\n  if (!gen) {\n    throw new GeneratorError(\n      `Generator ${qualifiedName(generator)} not found`,\n      { type: \"plop_generator_not_found\" }\n    );\n  }\n","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/vercel/turborepo/blob/9f94a7d215b3881942527dd526afa3fc650869d5/packages/turbo-gen/src/utils/plop.ts#L339-L375","documentation":"runCustomGenerator bundles your generator config with esbuild and loads it through nodePlop. If nodePlop throws while loading (the original error is printed to stderr first, then createPlopFromConfig returns undefined), turbo-gen throws GeneratorError 'Unable to load generators' (type plop_unable_to_load_config). The config exists but cannot be loaded as a plop config.","triggerScenarios":"The config file throws at module top level when executed; it does not default-export a plop config function `export default function (plop) {...}`; it imports a dependency that cannot be resolved from your project (only @inquirer/prompts is CLI-provided).","commonSituations":"TS configs importing packages not installed in that workspace; exporting a const or named export instead of a default function; refactors introducing a runtime error; CJS/ESM confusion where module.exports ends up double-wrapped.","solutions":["Look at the line printed immediately before this error — the real load exception is logged there by createPlopFromConfig","Run the config standalone to reproduce: `npx tsx turbo/generators/config.ts`","Make the config default-export a function: `export default function (plop) { plop.setGenerator(...) }`","Install any packages the config imports (only `@inquirer/prompts` is provided by the CLI without installing)"],"exampleFix":"// turbo/generators/config.ts (before)\nexport const config = (plop: NodePlopAPI) => { plop.setGenerator(...) };\n// after\nexport default function (plop: NodePlopAPI) { plop.setGenerator(...) }","handlingStrategy":"try-catch","validationCode":"import path from 'node:path';\nimport { build } from 'esbuild';\n\nasync function configLoads(configPath: string): Promise<boolean> {\n  try {\n    await build({ entryPoints: [configPath], bundle: true, format: 'cjs', platform: 'node', write: false, logLevel: 'silent' });\n    return true;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runCustomGenerator({ project, generator, configPath });\n} catch (err) {\n  if (err instanceof GeneratorError && err.type === 'plop_unable_to_load_config') {\n    // the real load error was printed to stderr just before this throw — inspect it,\n    // then surface a targeted message about default-export shape or missing deps\n    throw new Error(`generator config failed to load — check default export and imports`);\n  }\n  throw err;\n}","preventionTips":["Always default-export a plop config function: `export default function (plop) { ... }`","Run `npx tsx turbo/generators/config.ts` after config changes to catch load errors early","Install every package the config imports; only @inquirer/prompts is injected by the CLI"],"tags":["turbo-gen","generator","plop","config","module-loading"],"backgroundTag":"config-load-failed","analyzedSha":"9f94a7d215b3881942527dd526afa3fc650869d5","analyzedAt":"2026-08-16T19:47:29.531Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}