MichaelE
MichaelE

Reputation: 767

AXIOS_INSTANCE_TOKEN error in Nestjs startup

My nestjs app starts to blow up pointing to AXIOS_INSTANCE_TOKEN error and request for the module containing AXIOS_INSTANCE_TOKEN to be imported... the thing is the only module using Axios is HttpModule and it was imported from the start. this is what I have:

the error:

] [Nest] 94322   - 02/04/2021, 12:16:31 PM   [Genysis Gateway] Start Gateway
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [NestFactory] Starting Nest application...
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [InstanceLoader] RavenModule dependencies initialized
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [InstanceLoader] MsConnectorModule dependencies initialized
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [InstanceLoader] ChatModule dependencies initialized
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [InstanceLoader] HttpModule dependencies initialized
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [InstanceLoader] HttpModule dependencies initialized
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [InstanceLoader] HttpModule dependencies initialized
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [InstanceLoader] ConfigHostModule dependencies initialized
[0] [Nest] 94322   - 02/04/2021, 12:16:32 PM   [ExceptionHandler] Nest can't resolve dependencies of the HttpService (?). Please make sure that the argument AXIOS_INSTANCE_TOKEN at index [0] is available in the AppModule context.
[0] 
[0] Potential solutions:
[0] - If AXIOS_INSTANCE_TOKEN is a provider, is it part of the current AppModule?
[0] - If AXIOS_INSTANCE_TOKEN is exported from a separate @Module, is that module imported within AppModule?
[0]   @Module({
[0]     imports: [ /* the Module containing AXIOS_INSTANCE_TOKEN */ ]
[0]   })

THIS IS THE APP MODULE:

......   
@Module({
  imports: [
    RavenModule,
    ConfigModule.forRoot({
     isGlobal: true,
     load: [configuration],
       }),
    HttpModule.register({
        timeout: 5000,
        maxRedirects: 5,
      }),   
    AuthModule,
    UserModule,
   .......

I noticed that the three references to HttpModule initialized ok. Also, I have a check and the two other modules with HttpModules have correctly imported HttpModule in the Module and the injected the HttpService in the Service. I also noticed that the build died while building ConfigModule...not sure what that means?.... I have also deleted node_modules and run npm I twice and upgrade my nestjs/common from 7.5.1 to 7.6.11 all to no avail.

I would really appreciate any insights on this! Thanks in advance.

Upvotes: 0

Views: 3490

Answers (2)

Ifenna Okafor
Ifenna Okafor

Reputation: 11

I had this issue. your appModule is Ok all you need to do is to remove the HttpService from the provider and import HttpModule in order to have HttpService provider available to use. also see https://docs.nestjs.com/techniques/http-module#getting-started

Upvotes: 0

MichaelE
MichaelE

Reputation: 767

Apparently I somehow included HttpService in the app module as a provider and exported it also. Removing both entries resolved the problem.

Upvotes: 0

Related Questions