facebook/docusaurus · error · Error

Copying Docusaurus template name=${source.template.name} fai

Error message

Copying Docusaurus template name=${source.template.name} failed!

What it means

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.

Source

Thrown at packages/create-docusaurus/src/index.ts:508

  logger.info('Creating new Docusaurus project...');

  if (source.type === 'git') {
    if (!(await runGitCloneCommand(source, dest))) {
      logger.error`Cloning Git template failed!`;
      process.exit(1);
    }
    if (source.strategy === 'copy') {
      await fs.rm(path.join(dest, '.git'), {
        force: true,
        recursive: true,
      });
    }
  } else if (source.type === 'template') {
    try {
      await copyTemplate(source.template, dest, source.language);
    } catch (err) {
      throw new Error(
        logger.interpolate`Copying Docusaurus template name=${source.template.name} failed!`,
        {cause: err},
      );
    }
  } else {
    try {
      await fs.cp(source.path, dest, {recursive: true});
    } catch (err) {
      throw new Error(
        logger.interpolate`Copying local template path=${source.path} failed!`,
        {cause: err},
      );
    }
  }

  // Update package.json info.
  try {
    await updatePkg(path.join(dest, 'package.json'), {

View on GitHub (pinned to 3f483e80e3)

Solutions

  1. Reinstall create-docusaurus cleanly: npm uninstall -g create-docusaurus && npx create-docusaurus@latest <site>.
  2. Clear the package cache (npm cache clean --force / pnpm store prune) and retry.
  3. Check the cause property of the error for the underlying ENOENT/EACCES code and fix permissions or free disk space.
  4. If on a restricted filesystem, scaffold into a writable directory or use --skip-install to isolate the copy step.
Defensive patterns

Strategy: try-catch

Validate before calling

import {pathExists} from './utils.js';
import path from 'node:path';
// before calling init, verify the installed package ships its templates
const templatesOk = await pathExists(
  path.join(require.resolve('@docusaurus/utils/package.json'), '../../create-docusaurus/templates'),
);

Try / catch

try {
  await init(name, rootDir, template, cliOptions);
} catch (err) {
  if (/Copying Docusaurus template/.test((err as Error).message)) {
    console.error('Template copy failed:', (err as Error & {cause?: Error}).cause);
    // reinstall create-docusaurus and retry once
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12). Data as JSON: /api/errors/cf96c19105a2e537. Report an issue: GitHub.