davila7/claude-code-templates · error · Error

Cloudflare component files not found at: ${componentsDir}

Error message

Cloudflare component files not found at: ${componentsDir}

What it means

The installer resolves the Cloudflare component's files to a local componentsDir and checks it with fs.pathExists before copying. If that path does not exist, it throws with the resolved location. This means the CLI's packaged catalog references a component folder that is absent on disk.

Source

Thrown at cli-tool/src/index.js:2916

    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 version
      const checkNode = () => {
        return new Promise((resolve) => {
          const check = spawn('node', ['--version'], { stdio: 'pipe' });

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Update to the latest CLI: npx claude-code-templates@latest --sandbox <name> (clear npx cache if needed: npx clear-npx-cache)
  2. Verify the component exists in the repo at cli-tool/components/sandbox/cloudflare/<name> and that the catalog entry's path matches
  3. If the path changed, run python scripts/generate_components_json.py and republish so paths are consistent
  4. Double-check the exact component slug (kebab-case, correct category) against components.json

Example fix

// before
throw new Error(`Cloudflare component files not found at: ${componentsDir}`);
// after — include the component name and a hint
throw new Error(`Cloudflare component '${componentData.name}' not found at ${componentsDir}. Run with @latest or verify the catalog entry.`);
Defensive patterns

Strategy: validation

Validate before calling

const ok = await fs.pathExists(componentsDir) && (await fs.readdir(componentsDir)).length > 0;
if (!ok) { console.error(`Missing or empty: ${componentsDir}`); process.exit(1); }

Try / catch

try { /* install */ } catch (e) { if (/files not found at:/.test(e.message)) { /* suggest @latest or verify slug */ } throw e; }

Prevention

When it happens

Trigger: Installing a Cloudflare sandbox component whose folder was deleted or renamed in the repo but is still listed in components.json; or the npm package was built with an incomplete copy of cli-tool/components/.

Common situations: Catalog regenerated after moving a component without updating paths; stale cached npx package version that predates the reorg; component name typo that happens to resolve to a nonexistent path.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/0eed492cd6dfa409. Report an issue: GitHub.