ionicBootstrap--Uncaught Invalid provider - only instances of Provider and Type are allowed


#1

Hello,

I updated to Beta 10, and run into this problem with ionicBootstrap which prevented the boot of ionic app

see my "“app.ts” code below:

import {Component, ViewChild} from '@angular/core';
import {ionicBootstrap, Platform, MenuController, Nav} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {HelloIonicPage} from './pages/hello-ionic/hello-ionic';
import {ListPage} from './pages/list/list';
import {SenderPage} from './pages/sender/sender';
import {Decoder, TransSender} from 'fbsts';
import {User} from './providers/user/user';
@Component({
  templateUrl: 'build/app.html',
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  // make HelloIonicPage the root (or first) page
  rootPage: any = HelloIonicPage;
  pages: Array<{title: string, component: any}>;

  constructor(
    private platform: Platform,
    private menu: MenuController
  ) {
    this.initializeApp();

    // set our app's pages
    this.pages = [
      { title: 'My First List', component: ListPage },
      { title: 'Anonymous', component: SenderPage },
      { title: 'Main Page', component: HelloIonicPage }
    ];
  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      User.toDevId();
    });
  }

  openPage(page) {
    // close the menu when clicking a link from the menu
    this.menu.close();
    // navigate to the new page if it is not the current page
    this.nav.setRoot(page.component);
  }
}

ionicBootstrap(MyApp,[User, Decoder, TransSender]);

the screen display of command “ionic serve -l -s -c”

wjz@hp0:~/ion/tsender$ ionic serve -l -s -c
(node:10660) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

Running ‘serve:before’ gulp task before serve
[15:43:38] Starting ‘clean’…
[15:43:38] Finished ‘clean’ after 141 ms
[15:43:38] Starting ‘watch’…
[15:43:38] Starting ‘sass’…
[15:43:38] Starting ‘html’…
[15:43:38] Starting ‘fonts’…
[15:43:38] Starting ‘scripts’…
[15:43:38] Finished ‘scripts’ after 231 ms
[15:43:38] Finished ‘fonts’ after 371 ms
[15:43:39] Finished ‘html’ after 576 ms
[15:43:41] Finished ‘sass’ after 2.66 s
ts-loader: Using typescript@1.8.10 and /home/wjz/ion/tsender/tsconfig.json
Hash: caf91385ac6dd57466c9
Version: webpack 1.13.1
Time: 13480ms
Asset Size Chunks Chunk Names
app.bundle.js 3.74 MB 0 [emitted] main
app.bundle.js.map 4.42 MB 0 [emitted] main
[15:43:55] Finished ‘watch’ after 17 s
[15:43:55] Starting ‘serve:before’…
[15:43:55] Finished ‘serve:before’ after 5.45 μs

Running live reload server: http://localhost:35729
Watching: www//*, !www/lib//*
√ Running dev server: http://localhost:8100
Ionic server commands, enter:
restart or r to restart the client app from the root
goto or g and a url to have the app navigate to the given url
consolelogs or c to enable/disable console log output
serverlogs or s to enable/disable server log output
quit or q to shutdown the server and exit

ionic $ serve /?ionicplatform=ios (www/index.html)
serve /?ionicplatform=android (www/index.html)
serve /?ionicplatform=windows (www/index.html)
serve /cordova.js (mocked)
serve /build/js/app.bundle.js
serve /build/js/es6-shim.min.js
serve /build/js/Reflect.js
serve /build/js/zone.js
serve /build/css/app.md.css
serve /build/css/app.wp.css
serve /build/css/app.ios.css
serve /build/fonts/roboto-regular.ttf
serve /build/fonts/noto-sans-regular.ttf
0 509854 error Uncaught Invalid provider - only instances of Provider and Type are allowed, got: undefined, http://localhost:8100/build/js/app.bundle.js, Line: 6544
0 509884 error Uncaught Invalid provider - only instances of Provider and Type are allowed, got: undefined, http://localhost:8100/build/js/app.bundle.js, Line: 6544
0 509913 error Uncaught Invalid provider - only instances of Provider and Type are allowed, got: undefined, http://localhost:8100/build/js/app.bundle.js, Line: 6544

yet if I remove the " Decoder, TransSender" out of the ionicBootstrap’s onject list (so it become “ionicBootstrap(MyApp,[User]);” ) then the ionic boots correctly.

the difference here is that, “Decoder” and “TransSender” are imported from an external npm package “fbsts”; “User” is a locally composed provider

my “ionic info”:

Your system information:

Cordova CLI: 6.2.0
Ionic Framework Version: 2.0.0-beta.10
Ionic CLI Version: 2.0.0-beta.30
Ionic App Lib Version: 2.0.0-beta.16
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.4 LTS
Node Version: v6.2.2

my “package.json”:

{
  "dependencies": {
    "@angular/common": "^2.0.0-rc.3",
    "@angular/compiler": "^2.0.0-rc.3",
    "@angular/core": "^2.0.0-rc.3",
    "@angular/http": "^2.0.0-rc.3",
    "@angular/platform-browser": "^2.0.0-rc.3",
    "@angular/platform-browser-dynamic": "^2.0.0-rc.3",
    "@angular/router": "^2.0.0-rc.2",
    "es6-shim": "^0.35.1",
    "fbsts": "^1.0.21",
    "ionic-angular": "^2.0.0-beta.10",
    "ionic-native": "^1.3.2",
    "ionicons": "3.0.0",
    "node-uuid": "^1.4.7",
    "reflect-metadata": "^0.1.3",
    "rxjs": "^5.0.0-beta.6",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "del": "2.2.1",
    "gulp": "3.9.1",
    "gulp-watch": "4.3.8",
    "ionic-gulp-fonts-copy": "^1.0.0",
    "ionic-gulp-html-copy": "^1.0.0",
    "ionic-gulp-sass-build": "^1.0.0",
    "ionic-gulp-scripts-copy": "^2.0.0",
    "ionic-gulp-webpack": "^2.0.0",
    "run-sequence": "1.2.1",
    "ts-loader": "^0.8.2",
    "typescript": "1.8.10",
    "typings": "1.3.1"
  },
  "cordovaPlugins": [
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [
    "android",
    "ios"
  ],
  "name": "tsender",
  "description": "tsender: An Ionic project",
  "license": "ISC",
  "repository": {
    "type": "git",
    "url": "git@bitbucket.org:gubneo/tsender.git"
  }
}

my “tsconfig.json”:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "removeComments": true
  },

  "filesGlob": [
    "**/*.ts",
    "!node_modules/**/*"
  ],
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }

}

any suggestions?
cheers