Nest js cannot resolve dependencies. in Auth service
Nest js cannot resolve dependencies. in Auth service
Nest can't resolve dependencies of the AuthService (?). Please verify whether [0] argument is available in the current context.
Please find my project repository
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)
1 Answer
1
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:
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 {}
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
well as I can see in your auth.module you dont have imports: [UserModule].. you can check my project with nest and angular on github too github.com/bojidaryovchev/nest-angular
– Божидар Йовчев
15 hours ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I have already exported. and Injected [services, controller].You can see my code available on gitlab. Thank you for helping me.
– Arpit Yadav
yesterday