angular/angular-cli · error · DependencyNotFoundException

Dependency not found.

Error message

Dependency not found.

What it means

PartiallyOrderedSet.add verifies that every declared dependency is already a member of the set; if any dependency was never added, it throws DependencyNotFoundException ('Dependency not found.'). The set requires all dependencies to be registered as items, even if added without ordering guarantees. This check runs before the circular-dependency check in add().

Source

Thrown at packages/angular_devkit/core/src/utils/partially-ordered-set.ts:113

        for (const dep of itemDeps) {
          if (!deps.has(dep)) {
            equal = false;
            break;
          }
        }
      }

      if (equal) {
        return this;
      } else {
        this._items.delete(item);
      }
    }

    // Verify all dependencies are part of the Set.
    for (const dep of deps) {
      if (!this._items.has(dep)) {
        throw new DependencyNotFoundException();
      }
    }

    // Verify there's no dependency cycle.
    this._checkCircularDependencies(item, deps);

    this._items.set(item, new Set(deps));

    return this;
  }

  delete(item: T): boolean {
    if (!this._items.has(item)) {
      return false;
    }

    // Remove it from all dependencies if force == true.
    this._items.forEach((value) => value.delete(item));

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Add the missing dependency first: set.add('b', []) before set.add('a', ['b'])
  2. Fix the dependency name to exactly match the registered item identifier
  3. Check registration order/conditional logic that skipped adding the dependency; ensure remove/delete doesn't leave dangling dependents

Example fix

// before
pos.add('build', ['compile-missing'])
// after
pos.add('compile', []);
pos.add('build', ['compile']);
Defensive patterns

Strategy: validation

Validate before calling

function assertDependenciesRegistered(pos: { has(item: unknown): boolean }, item: string, deps: Iterable<string>): void {
  const missing = [...deps].filter((d) => !pos.has(d));
  if (missing.length) {
    throw new Error(`Cannot add '${item}': dependencies not found: ${missing.join(', ')}`);
  }
}
// call before pos.add(item, deps)

Type guard

null

Try / catch

try {
  pos.add(item, deps);
} catch (e) {
  if ((e as Error).message === 'Dependency not found.') {
    // ensure the dependency is added first or fix the identifier spelling
  }
  throw e;
}

Prevention

When it happens

Trigger: add('a', ['b']) where 'b' was never added via this.add('b', ...), dependency names misspelled or differing in case, an earlier add of the dependency failed/short-circuited, items removed via delete/clear while others still reference them.

Common situations: Plugin/registry setups where the dependency plugin isn't loaded yet, renaming an item but not updating dependents, typos in dependency strings, loading order where dependents register before their dependencies in a lazy-initialized registry.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/a6cf3e621fdde87b. Report an issue: GitHub.