ruvnet/ruflo · error · Error

AIDefence package not available. Install with: npm install @

Error message

AIDefence package not available. Install with: npm install @claude-flow/aidefence

What it means

Error "AIDefence package not available. Install with: npm install @claude-flow/aidefence" thrown in ruvnet/ruflo.

Source

Thrown at v3/@claude-flow/cli/src/mcp-tools/security-tools.ts:75

    const aidefence = await import(packageName);
    const instance = aidefence.createAIDefence({ enableLearning: true });
    if (!instance) {
      throw new Error('createAIDefence returned null');
    }
    aidefenceInstance = instance;
    return instance;
  } catch (e) {
    // Package not found or failed to load
    const error = e as Error;
    if (!error.message?.includes('Cannot find package') && !error.message?.includes('ERR_MODULE_NOT_FOUND')) {
      // Different error - might be a real issue
      throw new Error(`AIDefence failed to load: ${error.message}`);
    }
  }

  // Don't attempt install more than once per session
  if (installAttempted) {
    throw new Error('AIDefence package not available. Install with: npm install @claude-flow/aidefence');
  }
  installAttempted = true;

  // Second attempt - auto-install and retry
  console.error(`[claude-flow] ${packageName} not found, attempting auto-install...`);
  const installed = await autoInstallPackage(packageName);

  if (!installed) {
    throw new Error('AIDefence package not available. Install with: npm install @claude-flow/aidefence');
  }

  // #1807 — auto-install lands the package somewhere Node's standard
  // resolver couldn't find on the FIRST attempt (npm-global installs are
  // a common offender). Try Node's resolver again first (it may have
  // picked up the new node_modules directory), then fall back to the
  // file:// + cache-bust import dance, then surface a clearly actionable
  // error if everything still fails.
  // Plain re-import (covers project-local installs that landed where Node

View on GitHub (pinned to 6b01dc5a68)

When it happens

Trigger: Thrown at v3/@claude-flow/cli/src/mcp-tools/security-tools.ts:75 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12). Data as JSON: /api/errors/5ac1073d34135483. Report an issue: GitHub.