使用“系统”模块编译时不加载Ngb

时间:2017-04-15 21:40:49

标签: angular typescript ng-bootstrap

我在Angular应用程序中使用NgB的标准配置,一切正常,我的NgB元素按预期运行,应用程序正确加载和运行。但是,我需要将tsconfig.json的一个选项从"module" : "commonjs"更改为"module" : "system",现在我收到以下错误:

Error: Cannot read property 'forRoot' of undefined
  Evaluating http://localhost:10100/app/app.module.js
  Evaluating http://localhost:10100/app/main.js
  Loading app
    at Object.execute (app.module.ts:31)
    at declarativeExecute (register-loader.js:677)
    at doEvaluate (register-loader.js:609)
    at doEvaluate (register-loader.js:596)
    at ensureEvaluate (register-loader.js:542)
    at register-loader.js:132
    at ZoneDelegate.invoke (zone.js:365)
    at Zone.run (zone.js:125)
    at zone.js:760
    at ZoneDelegate.invokeTask (zone.js:398)
    at Zone.runTask (zone.js:165)
    at drainMicroTaskQueue (zone.js:593)

来自我的app.module中注册NgBModule.forRoot的内容

完整tsconfig.json

{
    "compilerOptions": {
        "target": "es6",
        "module": "system",
        "moduleResolution": "node",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "sourceMap": true
    },
    "exclude": [
        "node_modules"
    ]
}

使用系统选项是不兼容的还是我缺少额外的配置/声明?

更新:添加system.config.js

(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
      '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@ng-bootstrap/ng-bootstrap': 'npm:@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js',
      'rxjs': 'npm:rxjs',
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

0 个答案:

没有答案