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
- 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.
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
- 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.
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
- Copying local template path=${source.path} failed!
- Failed to update package.json.
- Directory already exists at path=${dest}!
- Invalid command: ${command}
- Invalid package manager choice ${packageManager}. Must be on
AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12).
Data as JSON: /api/errors/cf96c19105a2e537.
Report an issue: GitHub.