bettercap/bettercap · error · Error

Dependency array must have arguments.

Error message

Dependency array must have arguments.

What it means

Thrown during Angular dependency resolution when a dependency is expressed as an array (the legacy multi-provider/`deps` style, e.g. `deps: [[Token]]` wrapping) but the inner array is empty. Angular resolves each `dep` entry and refuses an empty dependency array because there is nothing to inject.

Source

Thrown at modules/ui/ui/vendor.js:55063

    var compiler = getCompilerFacade();
    return deps.map(function (dep) { return reflectDependency(compiler, dep); });
}
function reflectDependency(compiler, dep) {
    var meta = {
        token: null,
        host: false,
        optional: false,
        resolved: compiler.R3ResolvedDependencyType.Token,
        self: false,
        skipSelf: false,
    };
    function setTokenAndResolvedType(token) {
        meta.resolved = compiler.R3ResolvedDependencyType.Token;
        meta.token = token;
    }
    if (Array.isArray(dep)) {
        if (dep.length === 0) {
            throw new Error('Dependency array must have arguments.');
        }
        for (var j = 0; j < dep.length; j++) {
            var param = dep[j];
            if (param === undefined) {
                // param may be undefined if type of dep is not set by ngtsc
                continue;
            }
            else if (param instanceof Optional || param.__proto__.ngMetadataName === 'Optional') {
                meta.optional = true;
            }
            else if (param instanceof SkipSelf || param.__proto__.ngMetadataName === 'SkipSelf') {
                meta.skipSelf = true;
            }
            else if (param instanceof Self || param.__proto__.ngMetadataName === 'Self') {
                meta.self = true;
            }
            else if (param instanceof Host || param.__proto__.ngMetadataName === 'Host') {
                meta.host = true;

View on GitHub (pinned to 8eca2820f3)

Solutions

  1. Remove the empty nested array or replace it with the actual token(s) the factory/class needs.
  2. If the dependency is optional, list the token and mark it `@Optional()` rather than leaving the array empty.
  3. Regenerate JIT-generated metadata (rebuild with ngtsc/AOT) so `deps` is populated correctly.
  4. Search codebase for `deps: []` / `deps: [[]]` patterns and fix them.

Example fix

// before
{ provide: MyService, useFactory: createMyService, deps: [] }
// after
{ provide: MyService, useFactory: createMyService, deps: [HttpClient, [new Optional(), CONFIG_TOKEN]] }
Defensive patterns

Strategy: validation

Validate before calling

function validateDeps(deps: unknown[]) {
  deps.forEach((d, i) => {
    if (Array.isArray(d) && d.length === 0) {
      throw new Error(`deps[${i}] is an empty array`);
    }
  });
}

Type guard

function isNonEmptyDep(dep: unknown): dep is [unknown, ...unknown[]] {
  return Array.isArray(dep) && dep.length > 0;
}

Try / catch

try {
  injector.get(MyService);
} catch (e) {
  if (e.message === 'Dependency array must have arguments.') {
    console.error('Fix provider deps for MyService');
  } else { throw e; }
}

Prevention

When it happens

Trigger: Declaring a provider or injection metadata with a nested empty array, e.g. `provide: X, useFactory: f, deps: []` in a position where a nested `[]` array is passed (e.g. `deps: [[]]`), or generated JIT metadata where ngtsc left an empty `[]`.

Common situations: Hand-written provider objects in `providers: []` of a module with accidental `deps: [[]]`, code-generated factories from older toolchains, or migrations from Angular 4-5 style provider syntax leaving stale empty arrays.

Related errors


AI-assisted analysis of bettercap/bettercap@8eca2820f3 (2026-09-02). Data as JSON: /api/errors/289756ab542b265c. Report an issue: GitHub.