Angular2-jwt: jwt.interceptor.d.ts & jwt.interceptor.js compile error

Created on 19 May 2018  ·  9Comments  ·  Source: auth0/angular2-jwt

Hey,

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';

stale

Most helpful comment

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.

All 9 comments

I have just installed angular2-jwt and I'm having the same issue: ERROR in node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,28): error TS2307: Cannot find module 'rxjs/internal/Observable'.

I'm using Observables elsewhere in the project with no issues.

Angular 5.2 and rxjs 5.5.10

@RobQuatela I'll try your workaround, thanks.

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.

@chenkie Thanks, yes the downgrade to 1.0.0 did the trick.

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:

ERROR in node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,10): error TS2305: Module '"/Users/.../site/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.

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.

@gibsonsyd are you getting this error with angular2-jwt v2? That's the version that targets Angular v6. Observable is imported like this in v2:

import { Observable } from "rxjs/internal/Observable";

Hi, same issue here with Angular 6.0.3 and rxjs 6.0.0 (Angular CLI 6.0.7)

@chenkie Mercy hahahahah

Same issue with angular 7.1 using angular2-jwt v2

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️

Was this page helpful?
0 / 5 - 0 ratings

Related issues

getglad picture getglad  ·  5Comments

mahendra2125 picture mahendra2125  ·  4Comments

tekkudoc picture tekkudoc  ·  5Comments

hang321 picture hang321  ·  4Comments

JaxonWright picture JaxonWright  ·  4Comments