Nest js无法解析依赖关系.在Auth服务中 [英] Nest js cannot resolve dependencies. in Auth service

查看:469
本文介绍了Nest js无法解析依赖关系.在Auth服务中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嵌套不能解析AuthService(?)的依赖项.请验证[0]参数在当前上下文中是否可用.

请找到我的项目存储库

嵌套认证测试

Error: Nest can't resolve dependencies of the AuthService (?). Please verify whether [0] argument is available in the current context.
    at Injector.lookupComponentInExports (/home/arpit/Documents/aquaapp/node_modules/@nestjs/core/injector/injector.js:129:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:697:11)
    at Object.<anonymous> (/home/arpit/Documents/aquaapp/node_modules/ts-node/src/_bin.ts:177:12)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
    at startup (internal/bootstrap/node.js:201:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
 1: node::Abort() [/usr/bin/node]
 2: 0x8d04d9 [/usr/bin/node]
 3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/bin/node]
 4: 0xb17d2c [/usr/bin/node]
 5: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/bin/node]
 6: 0x2176d1e042fd
Aborted (core dumped)

推荐答案

通常,当您遇到这样的异常时,其原因是您试图注入另一个模块的依赖项,并且该依赖项尚未在exports数组中导出.一个例子:

Usually when you get such exception its because you are trying to inject a dependency of another module and that dependency hasn't been exported in the exports array.. Here's an example:

假设您要在模块A中使用某些服务,以便在模块B中使用:

Lets say you have some service in module A that you want to use in module B:

@Injectable()
export class SampleService {}

@Module({
  exports: [SampleService]
})
export class ModuleA {}

@Module({
  imports: [ModuleA]
})
export class ModuleB {}

请记住,如果将ModuleA导入ModuleB中,而将ModuleB导入ModuleA中,则会得到循环依赖项错误.希望对您有所帮助

Keep in mind that if you import ModuleA in ModuleB and ModuleB in ModuleA you will get a circular dependency error.. I hope that helps

这篇关于Nest js无法解析依赖关系.在Auth服务中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆