authentication - Nest js 无法解析依赖项。在身份验证服务中
问题描述
Nest 无法解析 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)
解决方案
通常,当您遇到此类异常时,是因为您试图注入另一个模块的依赖项,并且该依赖项尚未在导出数组中导出。这是一个示例:
假设您在模块 A 中有一些要在模块 B 中使用的服务:
@Injectable()
export class SampleService {}
@Module({
exports: [SampleService]
})
export class ModuleA {}
@Module({
imports: [ModuleA]
})
export class ModuleB {}
请记住,如果您在 ModuleB 中导入 ModuleA,在 ModuleA 中导入 ModuleB,您将收到循环依赖错误。
推荐阅读
- node.js - 如何在带有 npm 的 PowerShell 中使用“@”
- r - 使用包含相同值的多个列进行更广泛的透视
- python - 使用 OpenCV 和 Python 读取具有透明度的 .png 图像
- r - 如何一起使用 filter across 和 str_detect 来过滤多列的条件
- reactjs - 如何将数据从一个子组件传递到另一个兄弟组件?
- c++ - SetWindowLong 与 DWL_MSGRESULT
- javascript - Node.js Mongoose 填充数据未显示
- flutter - 补丁叫做return empty
- c# - 作为服务运行时 C# RSA 解密失败
- c++ - C++ 64 位乘法给出 128 位数