{"record":{"id":"72c0a32f867d770c","repo":"vercel/turborepo","slug":"plop-unable-to-load-config","errorCode":"plop_unable_to_load_config","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/f9245100cf0d31d96628804ead485f6bf226e55a/packages/turbo-gen/src/utils/plop.ts#L339-L375","documentation":"turbo-gen loads your generator config by bundling it with esbuild and handing it to node-plop. createPlopFromConfig returns undefined when node-plop rejects the config, logs the underlying error, and cleans up the bundled file. This GeneratorError with code plop_unable_to_load_config is thrown when that load produced no plop instance.","triggerScenarios":"The config file exists but does not work as a plop config: it does not export a function that receives plop, it throws during evaluation, or it imports something that fails to resolve. nodePlop() rejects, the catch returns undefined, and the caller converts that to this GeneratorError.","commonSituations":"module.exports = { ... } instead of module.exports = (plop) => { ... }. A plopfile written as ESM default export but loaded as CJS, or the reverse. A syntax error or missing dependency inside the config. TypeScript types stripped incorrectly during bundling.","solutions":["Look at the error line logged just above; it is the real load failure from node-plop or esbuild","Make the config export a function: module.exports = function (plop) { ... }","Match the file extension to your package type: use .cjs when \"type\": \"module\" is set","Ensure every import in the config resolves from the project"],"exampleFix":"// before: config exports an object\nmodule.exports = { generators: [] };\n// after: config exports a function that registers generators\nmodule.exports = function (plop) {\n  plop.setGenerator(\"hello\", {\n    prompts: [],\n    actions: [{ type: \"add\", path: \"hello.txt\", template: \"hi\" }]\n  });\n};","handlingStrategy":"try-catch","validationCode":"// smoke-load the config the same way turbo-gen does before running generators\nimport nodePlop from \"node-plop\";\n\nconst plop = await nodePlop(configPath, { destBasePath: root, force: false });\nif (!plop) throw new Error(\"Unable to load generators\");","typeGuard":"import type { NodePlopAPI } from \"node-plop\";\n\nfunction isPlopInstance(value: unknown): value is NodePlopAPI {\n  return typeof value === \"object\" && value !== null && typeof (value as NodePlopAPI).getGenerator === \"function\";\n}","tryCatchPattern":"try {\n  await runPlopGenerator(args);\n} catch (err) {\n  if (err instanceof GeneratorError && err.type === \"plop_unable_to_load_config\") {\n    // the real load error was logged above; fix the config export and retry\n    console.error(\"Config failed to load. Ensure it exports a function: module.exports = (plop) => {...}\");\n    process.exitCode = 1;\n  } else {\n    throw err;\n  }\n}","preventionTips":["Always export a function from plop configs, not an object","Match config file extension to your package module type","Load-test generator configs in CI with node-plop directly"],"tags":["turbo-gen","plop","config","module-loading","esbuild"],"backgroundTag":"config-module-load-failed","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}