{"record":{"id":"cf96c19105a2e537","repo":"facebook/docusaurus","slug":"copying-docusaurus-template-name-source-template","errorCode":null,"errorMessage":"Copying Docusaurus template name=${source.template.name} failed!","messagePattern":"Copying Docusaurus template name=(.+?) failed!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/create-docusaurus/src/index.ts","lineNumber":508,"sourceCode":"\n  logger.info('Creating new Docusaurus project...');\n\n  if (source.type === 'git') {\n    if (!(await runGitCloneCommand(source, dest))) {\n      logger.error`Cloning Git template failed!`;\n      process.exit(1);\n    }\n    if (source.strategy === 'copy') {\n      await fs.rm(path.join(dest, '.git'), {\n        force: true,\n        recursive: true,\n      });\n    }\n  } else if (source.type === 'template') {\n    try {\n      await copyTemplate(source.template, dest, source.language);\n    } catch (err) {\n      throw new Error(\n        logger.interpolate`Copying Docusaurus template name=${source.template.name} failed!`,\n        {cause: err},\n      );\n    }\n  } else {\n    try {\n      await fs.cp(source.path, dest, {recursive: true});\n    } catch (err) {\n      throw new Error(\n        logger.interpolate`Copying local template path=${source.path} failed!`,\n        {cause: err},\n      );\n    }\n  }\n\n  // Update package.json info.\n  try {\n    await updatePkg(path.join(dest, 'package.json'), {","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/create-docusaurus/src/index.ts#L490-L526","documentation":"Thrown when copyTemplate() fails while copying one of the built-in templates (e.g. 'classic') from packages/create-docusaurus/templates into the destination directory. The original error is preserved as `cause`. copyTemplate is the path used for source.type === 'template', as opposed to git-clone or local-path templates.","triggerScenarios":"Selecting a built-in template name whose files are missing or corrupted in the installed create-docusaurus package; a permissions or disk-space failure during fs.cp of the template tree; a partially installed global create-docusaurus whose templates directory was pruned.","commonSituations":"Using a globally installed create-docusaurus that was installed with --omit=optional or pruned; a corrupt npm cache delivering an incomplete package; read-only filesystem in a sandboxed CI runner; a custom template name that matched the built-in list but whose tsVariantPath was expected and missing.","solutions":["Reinstall create-docusaurus cleanly: npm uninstall -g create-docusaurus && npx create-docusaurus@latest <site>.","Clear the package cache (npm cache clean --force / pnpm store prune) and retry.","Check the cause property of the error for the underlying ENOENT/EACCES code and fix permissions or free disk space.","If on a restricted filesystem, scaffold into a writable directory or use --skip-install to isolate the copy step."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import {pathExists} from './utils.js';\nimport path from 'node:path';\n// before calling init, verify the installed package ships its templates\nconst templatesOk = await pathExists(\n  path.join(require.resolve('@docusaurus/utils/package.json'), '../../create-docusaurus/templates'),\n);","typeGuard":null,"tryCatchPattern":"try {\n  await init(name, rootDir, template, cliOptions);\n} catch (err) {\n  if (/Copying Docusaurus template/.test((err as Error).message)) {\n    console.error('Template copy failed:', (err as Error & {cause?: Error}).cause);\n    // reinstall create-docusaurus and retry once\n  } else throw err;\n}","preventionTips":["Pin create-docusaurus to a known-good version rather than @latest in CI.","Install cleanly (no --no-optional / no prune) so template assets survive.","Catch the wrapped error and inspect cause.code before retrying."],"tags":["create-docusaurus","template","filesystem","wrapped-error"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}