The following error occurs when trying to implement the tutorial's Cat model for Mongo integration:
Nest can't resolve dependencies of the CatService (?). Please make sure that the argument CatModel at index [0] is available in the CatModule context.
[10:03:44 AM] Starting compilation in watch mode...
[10:03:47 AM] Found 0 errors. Watching for file changes.
[Nest] 25330 - 04/25/2023, 10:03:48 AM LOG [NestFactory] Starting Nest application...
[Nest] 25330 - 04/25/2023, 10:03:48 AM LOG [InstanceLoader] MongooseModule dependencies initialized +37ms
[Nest] 25330 - 04/25/2023, 10:03:48 AM ERROR [ExceptionHandler] Nest can't resolve dependencies of the CatService (?). Please make sure that the argument CatModel at index [0] is available in the CatModule context.
Potential solutions:
- Is CatModule a valid NestJS module?
- If CatModel is a provider, is it part of the current CatModule?
- If CatModel is exported from a separate @Module, is that module imported within CatModule?
@Module({
imports: [ /* the Module containing CatModel */ ]
})
Error: Nest can't resolve dependencies of the CatService (?). Please make sure that the argument CatModel at index [0] is available in the CatModule context.
Potential solutions:
- Is CatModule a valid NestJS module?
- If CatModel is a provider, is it part of the current CatModule?
- If CatModel is exported from a separate @Module, is that module imported within CatModule?
@Module({
imports: [ /* the Module containing CatModel */ ]
})
at Injector.lookupComponentInParentModules (/project/home/sagimann/workspace/node_modules/@nestjs/core/injector/injector.js:247:19)
at Injector.resolveComponentInstance (/project/home/sagimann/workspace/node_modules/@nestjs/core/injector/injector.js:200:33)
at resolveParam (/project/home/sagimann/workspace/node_modules/@nestjs/core/injector/injector.js:120:38)
at async Promise.all (index 0)
at Injector.resolveConstructorParams (/project/home/sagimann/workspace/node_modules/@nestjs/core/injector/injector.js:135:27)
at Injector.loadInstance (/project/home/sagimann/workspace/node_modules/@nestjs/core/injector/injector.js:61:13)
at Injector.loadProvider (/project/home/sagimann/workspace/node_modules/@nestjs/core/injector/injector.js:88:9)
at /project/home/sagimann/workspace/node_modules/@nestjs/core/injector/instance-loader.js:49:13
at async Promise.all (index 3)
at InstanceLoader.createInstancesOfProviders (/project/home/sagimann/workspace/node_modules/@nestjs/core/injector/instance-loader.js:48:9)
Is there an existing issue for this?
Current behavior
The following error occurs when trying to implement the tutorial's Cat model for Mongo integration:
Nest can't resolve dependencies of the CatService (?). Please make sure that the argument CatModel at index [0] is available in the CatModule context.
Minimum reproduction code
https://codesandbox.io/p/sandbox/cool-silence-cfjplu
Steps to reproduce
yarn start:dev
Code overview below:
app.module:
cat module (all code together):
Expected behavior
The tutorial should work as expected, no errors should occur during startup
Package
Other package
@nestjs/mongoose
NestJS version
9.0.0
Packages versions
Node.js version
16.17.0
In which operating systems have you tested?
Other