【发布时间】:2019-01-12 01:54:16
【问题描述】:
我想在我的服务中使用 JwtHelperService 模块,但出现以下错误:
ERROR in node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,28): error TS2307: Cannot find module 'rxjs/internal/Observable'.
我的服务中有 isAuthenticated 功能。
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);
}
}
我的 Angular 版本也是 5.0
感谢您的帮助
【问题讨论】:
-
您使用的是 angular2-jwt 的第 2 版吗?
-
我安装了 npm install --save @auth0/angular-jwt
-
哪个版本的角度?
-
angular版本是5.0
-
你使用了错误的版本,试试angular2-jwt,它与Angular v5和RxJS v5兼容。
标签: angular typescript jwt token