davila7/claude-code-templates · error · Error

Claude Code projects directory not found at ${this.projectsD

Error message

Claude Code projects directory not found at ${this.projectsDir}

What it means

Thrown by TeamsDashboard.initialize() in cli-tool/src/teams-dashboard.js when the Claude Code projects directory (~/.claude/projects by default) does not exist. The dashboard discovers team sessions by scanning that directory, so without it there is nothing to show and initialization aborts.

Source

Thrown at cli-tool/src/teams-dashboard.js:23

const open = require('open');
const os = require('os');
const readline = require('readline');

class TeamsDashboard {
  constructor(options = {}) {
    this.options = options;
    this.app = express();
    this.port = 3338;
    this.httpServer = null;
    this.homeDir = os.homedir();
    this.claudeDir = path.join(this.homeDir, '.claude');
    this.projectsDir = path.join(this.claudeDir, 'projects');
    this.sessionCache = new Map();
  }

  async initialize() {
    if (!(await fs.pathExists(this.projectsDir))) {
      throw new Error(`Claude Code projects directory not found at ${this.projectsDir}`);
    }

    this.sessions = await this.discoverTeamSessions();
    this.setupWebServer();
  }

  async discoverTeamSessions() {
    const sessions = [];

    try {
      const projectDirs = await fs.readdir(this.projectsDir);

      for (const projectDir of projectDirs) {
        const projectPath = path.join(this.projectsDir, projectDir);
        const stat = await fs.stat(projectPath);
        if (!stat.isDirectory()) continue;

        const entries = await fs.readdir(projectPath);

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Run Claude Code once so it creates ~/.claude/projects, then retry
  2. Check the constructor args / env: confirm the claudeDir actually resolves to your Claude config dir (echo $HOME; ls ~/.claude)
  3. mkdir -p <projectsDir> if you only need the dashboard to start with zero sessions

Example fix

// before
if (!(await fs.pathExists(this.projectsDir))) {
  throw new Error(`Claude Code projects directory not found at ${this.projectsDir}`);
}

// after
if (!(await fs.pathExists(this.projectsDir))) {
  await fs.ensureDir(this.projectsDir); // start with an empty dashboard instead of crashing
}
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs-extra');
const path = require('path');
const projectsDir = path.join(process.env.HOME, '.claude', 'projects');
if (!(await fs.pathExists(projectsDir))) {
  throw new Error('Run Claude Code once first — no ~/.claude/projects directory');
}

Try / catch

try {
  await dashboard.initialize();
} catch (e) {
  if (/projects directory not found/.test(e.message)) {
    await fs.ensureDir(projectsDir);
    await dashboard.initialize(); // retry with an empty projects dir
  } else throw e;
}

Prevention

When it happens

Trigger: Instantiating TeamsDashboard and calling initialize() on a machine where Claude Code has never been run (no ~/.claude/projects), or where claudeDir/projectsDir were pointed at a custom non-existent path.

Common situations: Running the teams dashboard on a fresh machine or CI box before Claude Code has created any sessions; overriding the Claude directory to a wrong path; HOME env var pointing somewhere unexpected.

Related errors


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