davila7/claude-code-templates · error · Error
No files were copied from Cloudflare component directory
Error message
No files were copied from Cloudflare component directory
What it means
After copying a Cloudflare sandbox component's files into the sandbox directory, the installer re-reads the destination with fs.readdir and asserts it is non-empty. An empty result means the copy loop matched nothing (source dir empty, filter mismatch, or silent copy failures), so it aborts rather than proceeding with a broken sandbox.
Source
Thrown at cli-tool/src/index.js:2913
// Copy Cloudflare component files
const componentsDir = path.join(__dirname, '..', 'components', 'sandbox', 'cloudflare');
try {
if (await fs.pathExists(componentsDir)) {
console.log(chalk.gray('📦 Using local Cloudflare component files...'));
console.log(chalk.dim(` Source: ${componentsDir}`));
console.log(chalk.dim(` Target: ${sandboxDir}`));
// Copy all files from cloudflare directory
await fs.copy(componentsDir, sandboxDir, {
overwrite: true
});
// Verify files were copied
const copiedFiles = await fs.readdir(sandboxDir);
console.log(chalk.dim(` Copied ${copiedFiles.length} items`));
if (copiedFiles.length === 0) {
throw new Error('No files were copied from Cloudflare component directory');
}
} else {
throw new Error(`Cloudflare component files not found at: ${componentsDir}`);
}
} catch (error) {
spinner.fail(`Failed to install Cloudflare component: ${error.message}`);
throw error;
}
spinner.succeed('Cloudflare sandbox component installed successfully');
// Check for Node.js
const nodeSpinner = ora('Checking Node.js environment...').start();
try {
const { spawn } = require('child_process');
// Check Node.js versionView on GitHub (pinned to a0851ed10c)
Solutions
- Verify the component directory actually contains files: ls cli-tool/components/sandbox/cloudflare/<name>/ in the repo
- If files are missing upstream, reinstall the latest CLI (npx claude-code-templates@latest) so the package bundles a complete catalog
- Report/fix the component so its folder ships with its files, then regenerate components.json and republish
- If the source truly has no extra files but the install is valid, guard the emptiness check on the specific copy operation rather than the whole dir
Example fix
// before
const copiedFiles = await fs.readdir(sandboxDir);
if (copiedFiles.length === 0) {
throw new Error('No files were copied from Cloudflare component directory');
}
// after — only count files the copy step itself produced
const copiedFiles = (await fs.readdir(sandboxDir)).filter(f => copiedSet.has(f));
if (copiedFiles.length === 0) {
throw new Error(`No matching files copied from ${componentsDir} (filter mismatch)`);
} Defensive patterns
Strategy: validation
Validate before calling
const entries = await fs.readdir(componentsDir).catch(() => []);
if (entries.length === 0) { console.error(`Component dir empty: ${componentsDir}`); process.exit(1); } Try / catch
try { /* install */ } catch (e) { if (/No files were copied/.test(e.message)) { console.warn('Component package incomplete — update the CLI: npx claude-code-templates@latest'); process.exit(1); } throw e; } Prevention
- Run installs with @latest so the packaged catalog matches the shipped folders
- In CI, assert every catalog entry maps to a non-empty directory
When it happens
Trigger: Installing a Cloudflare sandbox component (`--sandbox cloudflare-<name>`) where the component's directory exists but contains no files matching the copy filter, or where the packaged/extracted components directory is empty.
Common situations: The npm package was published with the cloudflare component folder empty due to .gitignore/.npmignore rules; the component was renamed/deleted upstream while the catalog still lists it; the extracted temp dir was cleaned mid-install.
Related errors
- Cloudflare component files not found at: ${componentsDir}
- Failed to parse MCP content for ${componentData.name}: ${err
- Docker component files not found at: ${componentsDir}
- Claude Code projects directory not found at ${this.projectsD
- Failed to load skill
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/bb11edac2ac6f626.
Report an issue: GitHub.