Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

node.js - 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.

question from:https://stackoverflow.com/questions/66051038/axios-instance-token-error-in-nestjs-startup

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...