【问题标题】:Cannot find module 'rxjs/internal/Observable'找不到模块 'rxjs/internal/Observable'
【发布时间】: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


【解决方案1】:

这听起来像是 RxJS 版本不匹配。 angular2-jwt v2 针对 RxJS v6。要与 Angular v5 和 RxJS v5 一起使用,您应该使用 angular2-jwt v1。

【讨论】:

  • 我安装了 npm install --save @auth0/angular-jwt
  • 使用 npm install --save angular2-jwt
猜你喜欢
  • 2019-02-22
  • 1970-01-01
  • 1970-01-01
  • 2018-11-13
  • 2022-11-09
  • 2019-03-06
  • 1970-01-01
  • 2016-08-10
  • 2021-10-21
相关资源
最近更新 更多