auth0 / angular2-jwt

Helper library for handling JWTs in Angular apps
MIT License
2.63k stars 485 forks source link

Angular 9 error - Class JwtModule is not an Angular module #643

Closed davoutuk closed 4 years ago

davoutuk commented 4 years ago

Adding this library to my Angular9 project, in the Intellij IDE and I get the following error ...

Class JwtModule is not an Angular module

Sambego commented 4 years ago

Hey @davoutuk, I'm not seeing that error in my Intelij IDE, are you using a plugin that might cause this error?

Can you also double check your import is correct import { JwtModule } from '@auth0/angular-jwt';

davoutuk commented 4 years ago

See screen shot from my Intellij

image

I have been responding on the other ticket that concerns this matter. The project will build/compile

I have tried

.... and this had no affect.

Please advise what other measures I should be checking

Sambego commented 4 years ago

Hey @davoutuk, let's dig a bit deeper. Are you using any specific typescript or angular plugins? If so, can you update them, and let me know which ones you use, so I can try to reproduce this :)

davoutuk commented 4 years ago

See the 'package.json' fiel below...

{
  "name": "gd-clarity",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.1.0",
    "@angular/common": "~9.1.0",
    "@angular/compiler": "~9.1.0",
    "@angular/core": "~9.1.0",
    "@angular/forms": "~9.1.0",
    "@angular/platform-browser": "~9.1.0",
    "@angular/platform-browser-dynamic": "~9.1.0",
    "@angular/router": "~9.1.0",
    "@auth0/angular-jwt": "^4.0.0",
    "@clr/angular": "^3.0.1",
    "@clr/core": "^3.0.1",
    "@clr/icons": "^3.0.1",
    "@clr/ui": "^3.0.1",
    "@webcomponents/webcomponentsjs": "^2.4.3",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.0",
    "@angular/cli": "~9.1.0",
    "@angular/compiler-cli": "~9.1.0",
    "@angular/language-service": "~9.1.0",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  }
}

I'm using VMWare Clarity component library.

davoutuk commented 4 years ago

Any progress chasing this down?

ihayes-atypon commented 4 years ago

I've just updated my Intellij Ultimate to 20.1 and that seems to have fixed the problem

However, I had to change the module code to the following to remove IDE warnings

    JwtModule.forRoot({
      config: {
        tokenGetter:() => {
          return localStorage.getItem('access_token'); },
        whitelistedDomains: ['http://localhost:8080']
      }
    }),
Sambego commented 4 years ago

This should be fixed in version v.4.2.0 (#661)