deno icon indicating copy to clipboard operation
deno copied to clipboard

NestJS cannot resolve ModuleRef dependency after TerminusModule is added

Open lucassusanto opened this issue 1 year ago • 1 comments

Problem

  • NestJS cannot resolve ModuleRef dependency after TerminusModule is added
  • ./src/app.module.ts
    import { Module } from '@nestjs/common';
    import { TerminusModule } from '@nestjs/terminus';
    
    @Module({
      imports: [TerminusModule]
    })
    export class AppModule {}
    

How To Reproduce

  1. Clone the minimal reproducible project example

    git clone https://github.com/lucassusanto/nestjs-deno-terminus-issue
    
  2. Install the dependencies

    deno install
    
  3. Run the application

    deno run --allow-env --allow-net --allow-read src/main.ts
    
  4. NestJS won't start

    [Nest] 13408  - 10/20/2024, 3:06:53 PM   ERROR [ExceptionHandler] Nest can't resolve dependencies of the TypeOrmHealthIndicator (?). Please make sure that the argument ModuleRef at index [0] is available in the TerminusModule context.
    
    Potential solutions:
    - Is TerminusModule a valid NestJS module?
    - If ModuleRef is a provider, is it part of the current TerminusModule?
    - If ModuleRef is exported from a separate @Module, is that module imported within TerminusModule?
      @Module({
        imports: [ /* the Module containing ModuleRef */ ]
      })
    

Expected Result

  • NestJS should run without error
    [Nest] 13531  - 10/20/2024, 3:07:54 PM     LOG [NestApplication] Nest application successfully started +7ms
    

Additional Context

  • Deno version
    deno 2.0.2 (stable, release, x86_64-unknown-linux-gnu)
    v8 12.9.202.13-rusty
    typescript 5.6.2
    

lucassusanto avatar Oct 20 '24 08:10 lucassusanto

It also happens while I'm using pure deno—not node compat. Here is the minimal reproducible project: https://github.com/lucassusanto/nestjs-deno-terminus-issue/tree/deno-starter

lucassusanto avatar Oct 23 '24 05:10 lucassusanto

I'm facing the same issue on

deno 2.1.1 (stable, release, aarch64-apple-darwin) v8 13.0.245.12-rusty typescript 5.6.2

smartmeta avatar Nov 29 '24 09:11 smartmeta