When MongooseModule is used, an attempt to run the project results in
[Nest] 91872 - 07/03/2023, 3:31:50 PM ERROR [ExceptionHandler] Nest can't resolve dependencies of the MongooseCoreModule (MongooseConnectionName, ?). Please make sure that the argument ModuleRef at index [1] is available in the MongooseCoreModule context.
Minimum reproduction code
app.module.ts
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
@Module({
imports: [
MongooseModule.forRoot('mongodb://viar_user:M0ng0Pass%23ord%21@sl4.fusionworks.md:27017/'),
],
})
export class AppModule { }
main.ts
import { CommandFactory } from 'nest-commander';
import { AppModule } from './app.module';
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
async function bootstrap() {
console.log('start');
// const app = await NestFactory.create(AppModule)
const app = await CommandFactory.createWithoutRunning(AppModule, ['warn', 'error', 'debug', 'log']);
console.log('done');
}
bootstrap();
Console output
[Nest] 91872 - 07/03/2023, 3:31:50 PM ERROR [ExceptionHandler] Nest can't resolve dependencies of the MongooseCoreModule (MongooseConnectionName, ?). Please make sure that the argument ModuleRef at index [1] is available in the MongooseCoreModule context.
Potential solutions:
- Is MongooseCoreModule a valid NestJS module?
- If ModuleRef is a provider, is it part of the current MongooseCoreModule?
- If ModuleRef is exported from a separate @Module, is that module imported within MongooseCoreModule?
@Module({
imports: [ /* the Module containing ModuleRef */ ]
})
Expected behavior
Everything initialised as if using NestFactory.create
Is there an existing issue for this?
Current behavior
When MongooseModule is used, an attempt to run the project results in
Minimum reproduction code
app.module.ts
main.ts
Console output
Expected behavior
Everything initialised as if using NestFactory.create
Package
nest-commander
nest-commander-schematics
nest-commander-testing
Package version
^2.4.0
Node.js version
16
In which operating systems have you tested?
Other
No response