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

Lazy loaded module cannot access global module #12879

Closed
4 of 15 tasks
5d-jh opened this issue Dec 4, 2023 · 4 comments
Closed
4 of 15 tasks

Lazy loaded module cannot access global module #12879

5d-jh opened this issue Dec 4, 2023 · 4 comments
Labels
needs triage This issue has not been looked into

Comments

@5d-jh
Copy link

5d-jh commented Dec 4, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

This issue doesn't seem to been resolved on nestjs@9.

UnknownDependenciesException [Error]: Nest can't resolve dependencies of the ImportedService (?). Please make sure that the argument GLOBAL at index [0] is available in the ImportedModule context.

Potential solutions:
- Is ImportedModule a valid NestJS module?
- If GLOBAL is a provider, is it part of the current ImportedModule?
- If GLOBAL is exported from a separate @Module, is that module imported within ImportedModule?
  @Module({
    imports: [ /* the Module containing GLOBAL */ ]
  })

Minimum reproduction code

https://github.com/5d-jh/nest-lazy

Steps to reproduce

ts-node -T main.ts

Expected behavior

Nest should inject value hi to ImportedService, resulting to print hi on console.

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.4.3

Packages versions

{
  "name": "lazy",
  "version": "1.0.0",
  "dependencies": {
    "@nestjs/common": "9",
    "@nestjs/core": "9",
    "@nestjs/platform-express": "^10.2.10"
  },
  "devDependencies": {
    "ts-node": "^10.9.1",
    "typescript": "^5.3.2"
  }
}

Node.js version

18.18.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@5d-jh 5d-jh added the needs triage This issue has not been looked into label Dec 4, 2023
@kamilmysliwiec
Copy link
Member

Would you like to try creating a PR for this issue?

@5d-jh
Copy link
Author

5d-jh commented Dec 4, 2023

Sure. Would you mind if I create patch for 9.x?

@kamilmysliwiec
Copy link
Member

Sure, sounds good!

@kamilmysliwiec
Copy link
Member

Let's track this here #12880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants