[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
I get:
[Nest] 4578 - 10/10/2018, 4:43:26 PM [ExceptionHandler] Nest can't resolve dependencies of the HttpService (?). Please make sure that the argument at index [0] is available in thecurrent context. +24ms
The app should run just fine and the HttpService dependency can be injected in the AppModule.
Install cli and perform the following steps:
nest new app
import { Module, HttpService, HttpModule } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [HttpModule],
controllers: [AppController],
providers: [AppService, HttpService],
})
export class AppModule {}
npm run start
I would like to make some http requests in the nest app (download some files and then process them)
Nest version: 5.1.0
For Tooling issues:
- Node version: v10.9.0
- Platform: Mac
Others:
hey fixed this yet?
if not, you don't need to set HttpService as a provider, only the HttpModule as a import. the HttpService is injected in the provider you're going to use.
image from the docs.
@barretojs thanks. I updated from nestjs major version 4, and for some reason, I had the HttpService
listed in the providers. Nest-js version 4 won't complain about this.
Thanks again, closing the issue
I am getting the same error and have followed the above suggestions.
ERROR: Nest can't resolve dependencies of the HttpService (?). Please make sure that the argument at index [0] is available in the AppModule context.
at Injector.lookupComponentInExports (/project/node_modules/@nestjs/core/injector/injector.js:144:19)
Here is the BitcoinService file:
import { Injectable, HttpService } from '@nestjs/common';
@Injectable()
export class BitcoinService {
constructor(private http: HttpService) {
}
Here is the AppModule:
import { Module, HttpModule} from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { BitcoinController } from './bitcoin/bitcoin.controller';
import { BitcoinService } from './services/bitcoin.service';
@Module({
imports: [HttpModule],
controllers: [AppController, BitcoinController],
providers: [AppService, BitcoinService],
})
export class AppModule {}
[System Information]
OS Version : macOS High Sierra
NodeJS Version : v11.0.0
NPM Version : 6.4.1
[Nest Information]
common version : 5.4.0
core version : 5.4.0
Hi werewolf,
My issue was due to the missing reference.
I guess you would need to include 'BitcoinService' ref in your module. I had a separate ts file. so I just included it with the @Module ({components: [HERE_IT_GOES],}). Hope it helps.
I am getting the same error and have followed the above suggestions.
ERROR: Nest can't resolve dependencies of the HttpService (?). Please make sure that the argument at index [0] is available in the AppModule context.
at Injector.lookupComponentInExports (/project/node_modules/@nestjs/core/injector/injector.js:144:19)
Here is the BitcoinService file:
import { Injectable, HttpService } from '@nestjs/common'; @Injectable() export class BitcoinService { constructor(private http: HttpService) { }
Here is the AppModule:
import { Module, HttpModule} from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { BitcoinController } from './bitcoin/bitcoin.controller'; import { BitcoinService } from './services/bitcoin.service'; @Module({ imports: [HttpModule], controllers: [AppController, BitcoinController], providers: [AppService, BitcoinService], }) export class AppModule {}
[System Information]
OS Version : macOS High Sierra
NodeJS Version : v11.0.0
NPM Version : 6.4.1
[Nest Information]
common version : 5.4.0
core version : 5.4.0
I am getting the same error and have followed the above suggestions.
ERROR: Nest can't resolve dependencies of the HttpService (?). Please make sure that the argument at index [0] is available in the AppModule context.
at Injector.lookupComponentInExports (/project/node_modules/@nestjs/core/injector/injector.js:144:19)
Here is the BitcoinService file:
import { Injectable, HttpService } from '@nestjs/common'; @Injectable() export class BitcoinService { constructor(private http: HttpService) { }
Here is the AppModule:
import { Module, HttpModule} from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { BitcoinController } from './bitcoin/bitcoin.controller'; import { BitcoinService } from './services/bitcoin.service'; @Module({ imports: [HttpModule], controllers: [AppController, BitcoinController], providers: [AppService, BitcoinService], }) export class AppModule {}
[System Information]
OS Version : macOS High Sierra
NodeJS Version : v11.0.0
NPM Version : 6.4.1
[Nest Information]
common version : 5.4.0
core version : 5.4.0
@werewolfe, i was facing the same issues but this worked for me.
change your imports section to look like :
imports: [HttpModule.register({
timeout: 5000,
maxRedirects: 5,
}),],
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
hey fixed this yet?


if not, you don't need to set HttpService as a provider, only the HttpModule as a import. the HttpService is injected in the provider you're going to use.
image from the docs.