Angular2-jwt: Uncaught Invalid provider - only instances of Provider and Type are allowed

Created on 24 May 2016  路  8Comments  路  Source: auth0/angular2-jwt

When i add AUTH_PROVIDERS to

// App
export * from './app.component';
export * from './app.service';
export * from './app.settings';
import {AppState} from './app.service';
import {AUTH_PROVIDERS} from 'angular2-jwt';

// Application wide providers
export const APP_PROVIDERS = [
  AppState,
  AUTH_PROVIDERS
];

it throws error saying

zone.js:260 Uncaught Invalid provider - only instances of Provider and Type are allowed, got: [object Object]

Most helpful comment

I debugged it a bit. it seems that in _normalizeProviders it is failing for an instance check of type "Provider" which actually is the case.

Any ideas what is failing there? So are there multiple constructor functions for Providers? Don't get it...

All 8 comments

Try

export const APP_PROVIDERS = [
  AppState,
  ...AUTH_PROVIDERS
];

The spread operator (... ) will expand the auth providers array and plausibly fix the error.

@escardin it didn't fix the issue. Again, the same error is thrown

Does it work with Angular 2 rc1?

I and others have been using angular2-jwt with rc1 since this lib was updated with support for it weeks ago. Can you make a plunk recreating your issue? You can fork this one: http://plnkr.co/edit/ceYAhQeVHQQhC3QAwIFY?p=preview

Same problem for me. Any idea?

I debugged it a bit. it seems that in _normalizeProviders it is failing for an instance check of type "Provider" which actually is the case.

Any ideas what is failing there? So are there multiple constructor functions for Providers? Don't get it...

I'm having this problem with rc4. Everything worked great with rc1.

Angular2-jwt works just fine with rc4 http://plnkr.co/edit/vWJA9DhVGCV1U7k086Rx?p=preview Please reproduce the issue you're having in a plunk so we can fix it, or close the issue.

Was this page helpful?
0 / 5 - 0 ratings