Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CosmosDB Error on version 9+ #794

Closed
3 of 15 tasks
rrubio opened this issue Oct 4, 2022 · 13 comments
Closed
3 of 15 tasks

CosmosDB Error on version 9+ #794

rrubio opened this issue Oct 4, 2022 · 13 comments
Assignees

Comments

@rrubio
Copy link

rrubio commented Oct 4, 2022

Is there an existing issue for this?

  • 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
  • @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?

  • macOS
  • Windows
  • Linux

Other

No response

@micalevisk
Copy link
Member

micalevisk commented Oct 4, 2022

I believe we just need to remove the hard dep on @nestjs/common@8 at

"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",

image

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/nest Oct 4, 2022
@perpifran
Copy link

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
Copy link

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
Copy link

JohnBPG commented Jan 11, 2023

Any updates on this? I've noticed there is a PR to fix this from July: #725
Using overrides in package.json worked for me too, but I don't see it as a long term solution.

@ErwanBRANCHEREAU
Copy link

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

@Eugene-Murray
Copy link

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

@EmilEriksen
Copy link

@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
Copy link

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

any update for this issue?

@atomicleopard
Copy link

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

@michaelpoellath
Copy link

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
Copy link
Collaborator

I am working on upgrading this package. Please follow progress here: #884

@manekinekko manekinekko self-assigned this Jul 20, 2023
@zhucalvin
Copy link

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 */ ]
    })

@zhucalvin
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests