question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nest can't resolve dependencies of the JwtAuthenticationGuard after upgrade 8.1.0 to 8.1.1

See original GitHub issue

Did you read the migration guide?

  • I have read the whole migration guide

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Potential Commit/PR that introduced the regression

No response

Versions

No response

Describe the regression

After upgrade nest, in special @nestjs/passport, it started to throw an exception. Going back to 8.1.0 it works again.

The error

[Nest] 63736  - 14/02/2022, 17:05:19   ERROR [ExceptionHandler] Nest can't resolve dependencies of the JwtAuthenticationGuard. Please make sure that the "options" property is available in the current context.

Potential solutions:
- If AuthModuleOptions is a provider, is it part of the current EmailScheduleModule?
- If AuthModuleOptions is exported from a separate @Module, is that module imported within EmailScheduleModule?
  @Module({
    imports: [ /* the Module containing AuthModuleOptions */ ]
  })

Error: Nest can't resolve dependencies of the JwtAuthenticationGuard. Please make sure that the "options" property is available in the current context.

Potential solutions:
- If AuthModuleOptions is a provider, is it part of the current EmailScheduleModule?
- If AuthModuleOptions is exported from a separate @Module, is that module imported within EmailScheduleModule?
  @Module({
    imports: [ /* the Module containing AuthModuleOptions */ ]
  })

    at Injector.lookupComponentInParentModules (/Users/rvieceli/Projects/study/nestjs/wanago.io-nestjs/node_modules/@nestjs/core/injector/injector.js:202:19)
    at Injector.resolveComponentInstance (/Users/rvieceli/Projects/study/nestjs/wanago.io-nestjs/node_modules/@nestjs/core/injector/injector.js:157:33)
    at /Users/rvieceli/Projects/study/nestjs/wanago.io-nestjs/node_modules/@nestjs/core/injector/injector.js:260:38
    at async Promise.all (index 0)
    at Injector.resolveProperties (/Users/rvieceli/Projects/study/nestjs/wanago.io-nestjs/node_modules/@nestjs/core/injector/injector.js:251:27)
    at callback (/Users/rvieceli/Projects/study/nestjs/wanago.io-nestjs/node_modules/@nestjs/core/injector/injector.js:47:32)
    at Injector.resolveConstructorParams (/Users/rvieceli/Projects/study/nestjs/wanago.io-nestjs/node_modules/@nestjs/core/injector/injector.js:124:24)
    at Injector.loadInstance (/Users/rvieceli/Projects/study/nestjs/wanago.io-nestjs/node_modules/@nestjs/core/injector/injector.js:52:9)
    at Injector.loadInjectable (/Users/rvieceli/Projects/study/nestjs/wanago.io-nestjs/node_modules/@nestjs/core/injector/injector.js:70:9)
    at async Promise.all (index 0)
image

Minimum reproduction code

Look at my project https://github.com/rvieceli/wanago.io-nestjs

Expected behavior

It doesn’t depend on AuthModuleOptions

Other

[System Information]
OS Version     : macOS Big Sur
NodeJS Version : v16.14.0
NPM Version    : 8.3.1 

[Nest CLI]
Nest CLI Version : 8.2.0 

[Nest Platform Information]
platform-express version : 8.3.0
elasticsearch version    : 8.0.0
schematics version       : 8.0.5
passport version         : 8.1.1
schedule version         : 1.0.2
typeorm version          : 8.0.3
testing version          : 8.2.6
common version           : 8.3.0
config version           : 1.2.0
core version             : 8.3.0
cqrs version             : 8.0.2
jwt version              : 8.0.0
cli version              : 8.2.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jmcdo29commented, Feb 15, 2022

@cleytoncoro if you’d read the above comments in the issue, and the linked PR, you’d realize this already has a fix, and there’s solutions in the thread already. Kamil will most likely publish a patch or minor update for this once the PR is merged.

1reaction
jmcdo29commented, Feb 14, 2022

Only if

  1. you have a PassportModule.register() with options you want to have used (like user property )
  2. You have a guard that needs to AuthService

Otherwise, it shouldn’t really be necessary, but it is at the moment because of the change

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nest can't resolve dependencies of the AuthGuard (Guard ...
I want use this Guard in controllers to check authentication. I've this error: Nest can't resolve dependencies of the AuthGuard (?, +).
Read more >
[8.1.1] - Nest can't resolve dependencies of the JwtAuthGuard ...
error: Nest can't resolve dependencies of the JwtAuthGuard. Please make sure that the "options" property is available in the current context.
Read more >
Authentication | NestJS - A progressive Node.js framework
Authenticate a user by verifying their "credentials" (such as username/password, JSON Web Token (JWT), or identity token from an Identity Provider); Manage ...
Read more >
Handling authentication in GraphQL – Part 2: JWT - Pusher Blog
These are all the dependencies for our GraphQL server and the authentication system. We'll go over each of them as we begin to...
Read more >
NestJs JWT - Access Tokens & Refresh Tokens - Ultimate Guide
In this video, I will be building a complete authentication module with logout and refresh functionality. I will also show how you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found