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 .gitignoreView on GitHub (pinned to 3f483e80e3)
Solutions
- Verify the template path exists and is a directory: ls -la ./my-template.
- Use an absolute path to avoid cwd ambiguity: create-docusaurus my-site $(pwd)/my-template.
- Inspect err.cause.code (ENOENT/EACCES/ENOSPC) and resolve the underlying filesystem issue.
- 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
- Pass an absolute path for local templates.
- Pre-validate the path is a readable directory before invoking init.
- Keep templates free of broken symlinks and unreadable files.
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
- Copying Docusaurus template name=${source.template.name} fai
- 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/36e6f2e70a30c832.
Report an issue: GitHub.