nestjs/nest · error · InvalidClassModuleException

"${metatype.name}" is decorated with @Catch() and cannot app

Error message

"${metatype.name}" is decorated with @Catch() and cannot appear in the "imports" array of a module. Please move "${metatype.name}" to the "providers" array (using the APP_FILTER token to apply it globally) or apply it via @UseFilters() instead.

Scope [${scope}]

What it means

Error ""${metatype.name}" is decorated with @Catch() and cannot appear in the "imports" array of a module. Please move "${metatype.name}" to the "providers" array (using the APP_FILTER token to apply it globally) or apply it via @UseFilters() instead. Scope [${scope}] " thrown in nestjs/nest.

Source

Thrown at packages/core/scanner.ts:213

      ? moduleDefinition.forwardRef()
      : moduleDefinition;

    if (this.isInjectable(moduleToAdd)) {
      throw new InvalidClassModuleException(
        moduleDefinition,
        scope,
        'provider',
      );
    }
    if (this.isController(moduleToAdd)) {
      throw new InvalidClassModuleException(
        moduleDefinition,
        scope,
        'controller',
      );
    }
    if (this.isExceptionFilter(moduleToAdd)) {
      throw new InvalidClassModuleException(moduleDefinition, scope, 'filter');
    }

    return this.container.addModule(moduleToAdd, scope);
  }

  public async scanModulesForDependencies(
    modules: Map<string, Module> = this.container.getModules(),
  ) {
    for (const [token, { metatype }] of modules) {
      await this.reflectImports(metatype, token, metatype.name);
      this.reflectProviders(metatype, token);
      this.reflectControllers(metatype, token);
      this.reflectExports(metatype, token);
    }
  }

  public async reflectImports(
    module: Type<unknown>,

View on GitHub (pinned to dd75d7bd8c)

When it happens

Trigger: Thrown at packages/core/scanner.ts:213 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nestjs/nest@dd75d7bd8c (2026-08-21). Data as JSON: /api/errors/9838680a7290a512. Report an issue: GitHub.