Search code examples
angulartypescriptjwttoken

Cannot find module 'rxjs/internal/Observable'


I want to use JwtHelperService module in my service but I got below error:

ERROR in node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,28): error TS2307: Cannot find module 'rxjs/internal/Observable'.

I have isAuthenticated function in my service.

import { JwtHelperService } from '@auth0/angular-jwt';
import * as jwt_decode from 'jwt-decode';

@Injectable()
export class MembershipService{
    constructor(private http: Http,
       private mainService: MainService,
       public jwtHelper: JwtHelperService){}

    public isAuthenticated(): boolean {
        const token = localStorage.getItem('loggedToken');
        // Check whether the token is expired and return
        // true or false
        return !this.jwtHelper.isTokenExpired(token);

    }
}

Also my angular version is 5.0

I appreciate any help


Solution

  • it sounds like this is a mismatch of RxJS versions. angular2-jwt v2 targets RxJS v6. For use with Angular v5 and RxJS v5, you should use angular2-jwt v1.