无法将材质设计添加到Angular 4项目中

时间:2017-07-12 15:22:55

标签: node.js angular material-design

我尝试在官方教程(https://material.angular.io/guide/getting-started)之后将Material Design添加到我的项目中但是我收到错误:

node_modules/@angular/cdk/typings/rxjs/rx-operators.d.ts(11,10):错误TS2305:模块'“path_to_project / nod e_modules / rxjs / Scheduler“'没有导出成员'IScheduler'。 node_modules/@angular/platform-b​​rowser/animations/src/providers.d.ts(8,119):错误TS2305:模块'“path_to_project / node_modules / @ angular / animations / browser”'没有导出的成员'ɵDomAnimationEngine'。

我在论坛中找不到解决方案。

我的package.json:

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(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 bundles
      '@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-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.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',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
    '@angular/material': 'npm:@angular/material/bundles/material.umd.js',
    '@angular/cdk': 'npm:@angular/cdk/bundles/cdk.umd.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        defaultExtension: 'js',
        meta: {
          './*.js': {
            loader: 'systemjs-angular-loader.js'
          }
        }
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

和我的systemjs.config.js:

{{1}}

1 个答案:

答案 0 :(得分:1)

最新material-2.0.0-beta.8依赖于@angular/cdk,它依赖于rxjs版本5.0.3或更高版本。

所以你必须更改package.json中的rxjs版本:

npm install rxjs@5.0.3 --save

"rxjs": "~5.0.3"

此外,@angular/animations版本4.2.x知道issue

  

错误TS2305:模块'“path_to_project / node_modules / @ angular / animations / browser”'没有导出成员'ɵDomAnimationEngine'。

如果仍然出现此错误,则可能需要回退到4.1.x版。

npm install '@angular/animations"@4.1.3' --save