authentication - Nest js 无法解析依赖项。在授权服务中

标签 authentication jwt nestjs

Nest 无法解析 AuthService 的依赖项(?)。请验证 [0] 参数在当前上下文中是否可用。

请找到我的项目库

Nest-auth-test

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)

最佳答案

通常当你得到这样的异常时,它是因为你试图注入(inject)另一个模块的依赖项并且该依赖项尚未导出到 exports 数组中。这是一个例子:

假设您在模块 A 中有一些要在模块 B 中使用的服务:

@Injectable()
export class SampleService {}

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

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

请记住,如果您在 ModuleB 中导入 ModuleA 并在 ModuleA 中导入 ModuleB,则会出现循环依赖错误。

关于authentication - Nest js 无法解析依赖项。在授权服务中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51124374/

相关文章:

authentication - 如何在 Openssl 中自定义 TLS 握手过程?

使用 JWT token 进行 Azure AD 身份验证

Flask JWT token /有效载荷 - 返回用户 Json

javascript - nestjs multer 获取 multer 存储后的新文件名列表

azure-active-directory - 如何在 NestJS 中实现 Passport.js Azure AD 承载策略 (OpenID)

sql-server - SQL Server 2005 : How Secure is SQL Server Authentication?

swift - 如何更改 Moya 中的不记名 token

azure - 使用用户分配的托管标识连接到 Azure Databricks

security - JWT 优于数据库中简单随机生成的 token ?

node.js - 在 nest.js 代码库上找不到模块 (MODULE_NOT_FOUND)