jwt.interceptor.d.ts & jwt.interceptor.js compile error
See original GitHub issueHey,
This is my first time creating an issue. I am currently using Angular 5 with this library.
Issue:
I am getting an error when I compile because of a reference to “rxjs/internal/Observable” in the jwt.interceptor.d.ts file.
ERROR in node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,28): error TS2307: Cannot find module ‘rxjs/internal/Observable’.
Solution:
The solution I have for this to compile correctly using Angular 5 is to change that module reference in the jwt.interceptor.d.ts file from:
import { Observable } from 'rxjs/internal/Observable';
to:
import { Observable } from 'rxjs/observable';
and to change the module reference in jwt.interceptor.js from:
import { from } from "rxjs/internal/observable/from";
to:
import { from } from 'rxjs/observable/from';
Issue Analytics
- State:
- Created 5 years ago
- Reactions:14
- Comments:9 (2 by maintainers)
Are you using version 2 of angular2-jwt? If so, 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.
There is a compile error when using angular cli to build a project that has the angular2-jwt (npm 0.2.3) package reference:
Angular CLI: 6.0.3 Node: 8.9.4 OS: darwin x64 Angular: 6.0.2
`Package Version
@angular-devkit/architect 0.6.3 @angular-devkit/build-angular 0.6.3 @angular-devkit/build-optimizer 0.6.3 @angular-devkit/core 0.6.3 @angular-devkit/schematics 0.6.3 @angular/cli 6.0.3 @ngtools/webpack 6.0.3 @schematics/angular 0.6.3 @schematics/update 0.6.3 rxjs 6.1.0 typescript 2.7.2 webpack 4.8.3`
Build command:
ng build proj production
Error:
https://github.com/ReactiveX/rxjs indicates that Observable should be imported from ‘rxjs’ not ‘rxjs/Observable’ as it is declared in ‘jwt.interceptor.d.js’.
**EDIT
the rxjs-compat library is required to fix this issue currently. If not installed when upgrading an existing project through npm upgrade, you can run:
sudo npm install rxjs-compat --save
. This resolves the angular2-jwt issue when building the Angular 6 project.