[ExceptionHandler] Nest can't resolve dependencies of the FileService (?, +). Please verify whether [0] argument is available in the current context.
See original GitHub issueI’m submitting a…
[ ] 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.
Current behavior
Trying to use my fileRepository: Repository<File>
in my FileService, but I get the following error:
[ExceptionHandler] Nest can't resolve dependencies of the FileService (?, +). Please verify whether [0] argument is available in the current context.
Expected behavior
It should work
Minimal reproduction of the problem with instructions
I had no problem on other modules, I have no idea why I get this error on this one.
file.module.ts
@Module({
imports: [TypeOrmModule.forFeature([File]), GlobalModule],
components: [FileService, GlobalService],
controllers: [FileController],
})
export class FileModule {}
file.service.ts
constructor(@InjectRepository(File)
private readonly fileRepository: Repository<File>,
private globalService: GlobalService) {
}
app.module.ts
@Module({
imports: [TypeOrmModule.forRoot({
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: '',
database: 'thordetsv2',
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
synchronize: true,
}),
BugModule,
VersionModule,
FileModule
],
controllers: [AppController],
components: [],
})
What is the motivation / use case for changing the behavior?
bugfix
Environment
Nest version: 4.5.10
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:17 (3 by maintainers)
Top Results From Across the Web
Nest can't resolve dependencies of the (?). Please make sure ...
Please make sure that the argument at index [0] is available in the RootTestModule context. This project is using Mongoose for connecting to ......
Read more >nest can't resolve dependencies of the - You.com
Nest can't resolve dependencies of the PhotoService (?). Please verify whether [0] argument is available in the current context. I'm following the database ......
Read more >NestJS: Resolving Dependency Injection - Tevpro
Nest can't resolve dependencies of the AuthController (?). Please make sure that the argument dependency at index [0] is available in the AuthModule...
Read more >Nest can't resolve dependencies of the UsersService ... - Reddit
Please make sure that the argument User at index [0] is available in the RootTestModule context. Potential solutions: - If User is a...
Read more >How to avoid circular dependencies in NestJS - LogRocket Blog
NestJS code will not even compile if there is an unresolved circular dependency. In this article, we will be learning about circular ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
exports: [FileService]
in FileModule, import FileModule in BugModule and remove FileService from components in BugModuleif I do it like this, I am able to
npm start
the project without any issuesDo you also export the GlobalService within the GlobalModule as you are importing the GlobalService in your FileService? I think the FileModule itself seems to be correct. I have faced such an issue myself 😃 And I don’t think you need to import the GlobalService into your FileModule too.