NestJS ServeStaticModule. Nest can't resolve dependencies of the ServeStaticModule

Viewed 434

Couldn't find an answer anywhere for this error. I acted strictly according to the documentation. https://docs.nestjs.com/recipes/serve-static I installed the package

npm install --save @nestjs/serve-static

Next, I include the following code in my file:

ServeStaticModule.forRoot({rootPath: path.resolve(__dirname, 'static')}),

But I am getting this error:

eRROR [ExceptionHandler] Nest can't resolve dependencies of the ServeStaticModule (SERVE_STATIC_MODULE_OPTIONS, AbstractLoader, ?). Please make sure that the argument HttpAdapterHost at index [2] is available in the ServeStaticModule context.

Potential Solutions:

  • If HttpAdapterHost is a provider, is it part of the current ServeStaticModule?

  • If HttpAdapterHost is exported from a separate @Module, is that module imported within ServeStaticModule?

    @Module({ imports: [ /* the Module containing HttpAdapterHost */ ] })

0 Answers
Related