Object(...)不是函数-位于Module ../ node_modules/@angular/material/esm5/core.es5.js

时间:2018-12-24 10:02:46

标签: angular angular-material

我刚安装了材料:

npm install --save @angular/material @angular/cdk @angular/animations

导入的模块:

import { MatTabsModule } from '@angular/material/tabs';

question's答案表示这是由于动画版本不匹配所致。我不确定要更新什么。 @ angular / material是比angular依赖项更高的版本。这个问题的答案是说要安装较早版本的资料,但我只想使用最新的资料。

我尝试安装较旧版本的@ angular / material,但仍然无法正常工作。

npm ERR! notarget No matching version found for @angular/material@6.1.10

错误:

core.es5.js:1739 Uncaught TypeError: Object(...) is not a function
    at Module../node_modules/@angular/material/esm5/core.es5.js (core.es5.js:1739)
    at __webpack_require__ (bootstrap:78)
    at Module../node_modules/@angular/material/esm5/tabs.es5.js (tabs.es5.js:1)

package.json

{
  //...
  "dependencies": {
    "@angular/animations": "^6.1.10",
    "@angular/cdk": "^6.4.7",
    "@angular/common": "^6.1.10",
    "@angular/compiler": "^6.1.10",
    "@angular/core": "^6.1.10",
    "@angular/forms": "^6.1.10",
    "@angular/http": "^6.1.10",
    "@angular/material": "^7.2.0",
    "@angular/platform-browser": "^6.1.10",
    "@angular/platform-browser-dynamic": "^6.1.10",
    "@angular/router": "^6.1.10",
    "bootstrap": "^4.1.3",
    "core-js": "^2.5.4",
    "rxjs": "~6.2.0",
    "zone.js": "~0.8.26"
  },

更新:

我已更新到Angular 7,并且现在可以使用。

  "dependencies": {
    "@angular/animations": "^7.1.4",
    "@angular/cdk": "^7.2.0",
    "@angular/common": "^7.1.4",
    "@angular/compiler": "^7.1.4",
    "@angular/core": "^7.1.4",
    "@angular/forms": "^7.1.4",
    "@angular/http": "^7.1.4",
    "@angular/material": "^7.2.0",
    "@angular/platform-browser": "^7.1.4",
    "@angular/platform-browser-dynamic": "^7.1.4",
    "@angular/router": "^7.1.4",
    "bootstrap": "^4.1.3",
    "core-js": "^2.5.4",
    "rxjs": "~6.3.3",
    "zone.js": "~0.8.26"
  },

1 个答案:

答案 0 :(得分:0)

您必须使用以下命令->

@ angular / material 添加到您的角度cli中

ng添加@ angular / material