I'm encountering issues when attempting to include the Cosmos DB connection module in nestjs v9, as I'm facing dependency errors.
Nest is unable to resolve the dependencies of the AzureCosmosDbCoreModule (COSMOS_DB_CONNECTION_NAME, ?). Please ensure that the argument ModuleRef at index [1] is accessible within the AzureCosmosDbCoreModule context.
Possible remedies:
- If ModuleRef is a provider, is it included in the current AzureCosmosDbCoreModule?
- If ModuleRef is exported from another @Module, have you imported that module into AzureCosmosDbCoreModule?
@Module({
imports: [ /* the Module containing ModuleRef */ ]
})
When downgrading nestjs to version 8, the connection module functions as expected. The same code is used in both projects:
import { AzureCosmosDbModule } from '@nestjs/azure-database';
import { Module } from '@nestjs/common';
import { AppConfigModule } from '../shared/config/app-config.module';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [
AppConfigModule,
AzureCosmosDbModule.forRootAsync({
imports: [AppConfigModule],
useFactory: async (cfg: AppConfigModule) => ({
endpoint: cfg.get<string>('AZURE_COSMOS_DB_ENDPOINT'),
dbName: cfg.get<string>('AZURE_COSMOS_DB_TEST_NAME'),
key: cfg.get<string>('AZURE_COSMOS_DB_KEY'),
}),
inject: [AppConfigModule],
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Project information (not working): Node v16.16.0
"@azure/cosmos": "^3.17.0",
"@nestjs/azure-database": "^2.3.0",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
Project information (working): Node v16.16.0
"@nestjs/azure-database": "^2.3.0",
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",