facebook/docusaurus · error · Error

Copying local template path=${source.path} failed!

Error message

Copying local template path=${source.path} failed!

What it means

Thrown when fs.cp() fails while recursively copying a local template path (source.type === 'local'), i.e. when the user passes a filesystem path to a template directory instead of a built-in template name or git URL. The original fs error is attached as `cause`.

Source

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

      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'), {
      name: siteNameToPackageName(siteName),
      version: '0.0.0',
      private: true,
    });
  } catch (err) {
    throw new Error('Failed to update package.json.', {cause: err});
  }

  // We need to rename the gitignore file to .gitignore

View on GitHub (pinned to 3f483e80e3)

Solutions

  1. Verify the template path exists and is a directory: ls -la ./my-template.
  2. Use an absolute path to avoid cwd ambiguity: create-docusaurus my-site $(pwd)/my-template.
  3. Inspect err.cause.code (ENOENT/EACCES/ENOSPC) and resolve the underlying filesystem issue.
  4. Fix broken symlinks or unreadable files inside the template tree before retrying.

Example fix

# before
npx create-docusaurus my-site ./templat   # typo, path missing
# after
npx create-docusaurus my-site ./template
Defensive patterns

Strategy: validation

Validate before calling

import path from 'node:path';
import fs from 'node:fs/promises';
async function assertLocalTemplate(p: string) {
  const abs = path.resolve(p);
  const stat = await fs.stat(abs).catch(() => null);
  if (!stat?.isDirectory()) {
    throw new Error(`Local template path is not a directory: ${abs}`);
  }
}

Try / catch

try {
  await init(name, rootDir, localPath, cliOptions);
} catch (err) {
  if (/Copying local template/.test((err as Error).message)) {
    const code = (err as Error & {cause?: {code?: string}}).cause?.code;
    // ENOENT -> path typo; EACCES -> permissions
  }
  throw err;
}

Prevention

When it happens

Trigger: Running `create-docusaurus my-site ./my-template` where my-template is missing, not a directory, or unreadable; a local template that contains a file the current user cannot read; destination filesystem full mid-copy.

Common situations: Pointing --template at a relative path that does not resolve from cwd; using a template directory with broken symlinks; copying across filesystems/owners with permission mismatches; the path exists (so the local branch was chosen) but a nested entry is inaccessible.

Related errors


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