#Package issue

19 messages · Page 1 of 1 (latest)

golden hawk
#

Getting this issue not able to figure out please help me in this issue,

unreal brookBOT
#

Occasionally you'll find it difficult to avoid circular dependencies in your application.
You'll need to take some steps to help Nest resolve these. Errors that arise from circular dependencies look like this:

Nest cannot create the <module> instance.
The module at index [<index>] of the <module> "imports" array is undefined.

Potential causes:
- A circular dependency between modules. Use forwardRef() to avoid it.
- The module at index [<index>] is of type "undefined". Check your import statements and the type of the module.

Scope [<module_import_chain>]
# example chain AppModule -> FooModule

A circular dependency occurs when two classes depend on each other.
For example, class A needs class B, and class B also needs class A.
Circular dependencies can arise in Nest between modules and between providers.

While circular dependencies should be avoided where possible, you can't always do so.
In such cases, Nest enables resolving circular dependencies between providers in two ways.
In this chapter, we describe using forward referencing as one technique, and using the ModuleRef class to retrieve a provider instance from the DI container as another.

golden hawk
#

still getting the same issue, reflect-metadata version is 0.2.1
C:\Users\PoojaChakrawarti\Videos\VitaBotX-API-dev\node_modules\reflect-metadata\Reflect.js:549
var decorated = decorator(target);
^
Error: Token is undefined at index: 0. This often occurs due to circular dependencies.
Ensure there are no circular dependencies in your files or barrel files.
For more details, refer to https://trilon.io/blog/avoiding-circular-dependencies-in-nestjs.
at C:\Users\PoojaChakrawarti\Videos\VitaBotX-API-dev\node_modules@nestjs\common\decorators\core\inject.decorator.js:39:19
at C:\Users\PoojaChakrawarti\Videos\VitaBotX-API-dev\dist\apps\vitabotx-api\apps\vitabotx-api\src\feature-modules\on-boarding\services\on-boarding.service.js:12:37
at DecorateConstructor (C:\Users\PoojaChakrawarti\Videos\VitaBotX-API-dev\node_modules\reflect-metadata\Reflect.js:549:33)
at Reflect.decorate (C:\Users\PoojaChakrawarti\Videos\VitaBotX-API-dev\node_modules\reflect-metadata\Reflect.js:143:24)
at __decorate (C:\Users\PoojaChakrawarti\Videos\VitaBotX-API-dev\dist\apps\vitabotx-api\apps\vitabotx-api\src\feature-modules\on-boarding\services\on-boarding.service.js:4:92)
at Object.<anonymous> (C:\Users\PoojaChakrawarti\Videos\VitaBotX-API-dev\apps\vitabotx-api\src\feature-modules\on-boarding\services\on-boarding.service.ts:11:31)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Function.Module._load (node:internal/modules/cjs/loader:960:12)

#

don't have any circular dependency

#

@unreal brook have any solution

unreal brookBOT
#

Please do not tag the moderators unless someone is breaking server rules. The mods are here to help enforce the rules of the server, and while most of them are knowledgeable about Nest, they are not the only ones able to solve your question.

golden hawk
#

how do i resolve this issue?

crystal quartz
#

@golden hawk please run npm ls reflect-metadata