azure-database
azure-database copied to clipboard
CosmosDB Error on version 9+
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
On npm run start:dev getting the following error -
ERROR [ExceptionHandler] Nest can't resolve dependencies of the AzureCosmosDbCoreModule (COSMOS_DB_CONNECTION_NAME, ?)
Others having the same issue - https://stackoverflow.com/questions/73731641/how-to-establish-cosmos-db-database-connection-with-nestjs-v9-0-0
Potential solutions:
- If ModuleRef is a provider, is it part of the current AzureCosmosDbCoreModule?
- If ModuleRef is exported from a separate @Module, is that module imported within AzureCosmosDbCoreModule? @Module({ imports: [ /* the Module containing ModuleRef */ ] })
Error: Nest can't resolve dependencies of the AzureCosmosDbCoreModule (COSMOS_DB_CONNECTION_NAME, ?). Please make sure that the argument ModuleRef at index [1] is available in the AzureCosmosDbCoreModule context.
Minimum reproduction code
node 14 & 16, nestjs/common "^9.0.0"
Steps to reproduce
npm run start:dev
Using cosmos installation -
https://www.learmoreseekmore.com/2022/05/crud-operation-demo-on-nestjs-using-azure-cosmos-db.html
Expected behavior
Fetch data from cosmos db successfully.
Package
- [ ] I don't know. Or some 3rd-party package
- [X]
@nestjs/common - [ ]
@nestjs/core - [ ]
@nestjs/microservices - [ ]
@nestjs/platform-express - [ ]
@nestjs/platform-fastify - [ ]
@nestjs/platform-socket.io - [ ]
@nestjs/platform-ws - [ ]
@nestjs/testing - [ ]
@nestjs/websockets - [ ] Other (see below)
Other package
No response
NestJS version
9.1.2
Packages versions
{
"@azure/cosmos": "^3.17.1",
"@azure/functions": "^1.0.3",
"@nestjs/azure-database": "^2.3.0",
"@nestjs/azure-func-http": "^0.8.0",
"@nestjs/common": "^9.1.2",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.1.2",
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^9.1.2",
"@nestjs/sequelize": "^9.0.0",
"@nestjs/swagger": "^6.1.2",
"json2csv": "^5.0.7",
"jspdf": "^2.5.1",
"jspdf-autotable": "^3.5.25",
"moment": "^2.29.4",
"mysql2": "^2.3.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"sequelize": "^6.21.4",
"sequelize-typescript": "^2.1.3",
"tedious": "^15.0.1"
}
Node.js version
16.16.0
In which operating systems have you tested?
- [X] macOS
- [ ] Windows
- [ ] Linux
Other
No response
I believe we just need to remove the hard dep on @nestjs/common@8 at https://github.com/nestjs/azure-database/blob/d9abb1fbac3c43f8f0a1b3dc100b6ff2297408ce/package.json#L36-L37

hi, i love nestjs, and its integration with cosmos has been a relief. Will you guys fix the dependencies soon so I can use nestjs@9?
I got rid of the error by adding overrides to my package.json:
"overrides": {
"@nestjs/azure-database": {
"@nestjs/common": "^9.1.4",
"@nestjs/core": "^9.1.4"
}
}
You may need to delete node_modules, package-lock.json and reinstall.
I'm not sure if anything else is broken on v9.
Any updates on this? I've noticed there is a PR to fix this from July: https://github.com/nestjs/azure-database/pull/725 Using overrides in package.json worked for me too, but I don't see it as a long term solution.
Hi! Same probleme here. Any update? No response since last message (1 month ago)
The overrides did not work for me. Any update on the issue? Thanks
@Eugene-Murray Did you try deleting package-lock.json and node_modules and reinstalling? It seems to only work with a fresh install
I run in the same problem. deleting package-lock.json and node_modules doesnt work for me...
any update for this issue?
NestJS 10 is out, this issue seems to prevent this library being used with it. I was unable to resolve it with resolutions in package.json
I have the same Issue now when I upgrade to v10. A multitude of other issues arose with the overrides workaround due to our mono repo build process. Is there any way I can support here @kamilmysliwiec?
I am working on upgrading this package. Please follow progress here: https://github.com/nestjs/azure-database/pull/884
Having the same issue still:
[Nest] 32876 - 2023-10-05, 12:19:02 p.m. LOG [InstanceLoader] AzureCosmosDbModule dependencies initialized +40ms [Nest] 32876 - 2023-10-05, 12:19:02 p.m. ERROR [ExceptionHandler] Nest can't resolve dependencies of the AzureCosmosDbCoreModule (COSMOS_DB_CONNECTION_NAME, ?). Please make sure that the argument ModuleRef at index [1] is available in the AzureCosmosDbCoreModule context.
Potential solutions:
- Is AzureCosmosDbCoreModule a valid NestJS module?
- If ModuleRef is a provider, is it part of the current AzureCosmosDbCoreModule?
- If ModuleRef is exported from a separate @Module, is that module imported within AzureCosmosDbCoreModule? @Module({ imports: [ /* the Module containing ModuleRef */ ] })
Error: Nest can't resolve dependencies of the AzureCosmosDbCoreModule (COSMOS_DB_CONNECTION_NAME, ?). Please make sure that the argument ModuleRef at index [1] is available in the AzureCosmosDbCoreModule context.
Potential solutions:
- Is AzureCosmosDbCoreModule a valid NestJS module?
- If ModuleRef is a provider, is it part of the current AzureCosmosDbCoreModule?
- If ModuleRef is exported from a separate @Module, is that module imported within AzureCosmosDbCoreModule? @Module({ imports: [ /* the Module containing ModuleRef */ ] })
"dependencies": { "@angular/animations": "~16.2.0", "@angular/cdk": "^16.2.6", "@angular/common": "~16.2.0", "@angular/compiler": "~16.2.0", "@angular/core": "~16.2.0", "@angular/forms": "~16.2.0", "@angular/material": "^16.2.6", "@angular/platform-browser": "~16.2.0", "@angular/platform-browser-dynamic": "~16.2.0", "@angular/router": "~16.2.0", "@azure/cosmos": "^4.0.0", "@nestjs/azure-database": "^2.3.0", "@nestjs/common": "^10.0.2", "@nestjs/config": "^3.1.1", "@nestjs/core": "^10.0.2", "@nestjs/platform-express": "^10.0.2", "@nx/angular": "16.9.1", "axios": "^1.0.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "reflect-metadata": "^0.1.13", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.13.0" },