Reputation: 716
Getting error while instantiating the PaymentProcessorModule:
Error: Nest can't resolve dependencies of the PaymentProcessor (?, PaymentsService, ProcessingService). Please make sure that the argument TransactionsService at index [0] is available in the PaymentProcessor context.
Potential solutions:
- If TransactionsService is a provider, is it part of the current PaymentProcessor?
- If TransactionsService is exported from a separate @Module, is that module imported within PaymentProcessor?
@Module({
imports: [ /* the Module containing TransactionsService */ ]
})
However, both services come from the same module.
Here's my module:
@Module({
imports: [
TypeOrmModule.forFeature([ Transaction ]),
],
providers: [
PaymentProcessor,
TransactionsService,
TransactionsResolver,
],
exports: [PaymentProcessor],
})
export class PaymentProcessorModule {}
TransactionService:
@Injectable()
export class TransactionsService {
constructor(
@InjectRepository(Transaction) private transRepo: Repository<Transaction>,
) {}
//...
}
And finally, PaymentProcessor:
@Injectable()
export class PaymentProcessor {
constructor(
private transactions: TransactionsService,
private payments: PaymentsService,
private processor: ProcessingService,
) {}
//...
}
Expected to inject the TransactionsService. I could not seem to reproduce it in a sample repo, unfortunately.
Nest version: 7.4.1
Upvotes: 0
Views: 487
Reputation: 716
The official support of NestJS told me that the PaymentProcessor
must be mentioned in the imports
array somewhere. I checked for usages of the class and it's true, I accidentally imported the provider instead of the module in another context.
Upvotes: 1