nestjs / azure-database

Azure CosmosDB Database module for Nest framework (node.js) ☁️
https://nestjs.com
MIT License
106 stars 52 forks source link

CosmosDB Error on version 9+ #794

Closed rrubio closed 1 year ago

rrubio commented 2 years ago

Is there an existing issue for this?

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:

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

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?

Other

No response

micalevisk commented 2 years ago

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

image

perpifran commented 2 years ago

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?

EmilEriksen commented 2 years ago

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.

JohnBPG commented 1 year ago

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.

ErwanBRANCHEREAU commented 1 year ago

Hi! Same probleme here. Any update? No response since last message (1 month ago)

Eugene-Murray commented 1 year ago

The overrides did not work for me. Any update on the issue? Thanks

EmilEriksen commented 1 year ago

@Eugene-Murray Did you try deleting package-lock.json and node_modules and reinstalling? It seems to only work with a fresh install

philipp-reich commented 1 year ago

I run in the same problem. deleting package-lock.json and node_modules doesnt work for me...

any update for this issue?

atomicleopard commented 1 year ago

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

mwasl commented 1 year ago

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?

manekinekko commented 1 year ago

I am working on upgrading this package. Please follow progress here: https://github.com/nestjs/azure-database/pull/884

zhucalvin commented 1 year ago

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:

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:

zhucalvin commented 1 year ago

"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" },