无法在角4中编译材料,给出:/材料“没有导出成员的材料模块。

时间:2021-02-01 05:27:38

I am creating new Angular 4 app using Material UI Framework. I followed the steps given as : https://material.angular.io/guide/getting-started .

我正在创建新的角4应用使用材料UI框架。我按照给出的步骤:https://material.angle。io /指导/开始。

But when i am doing 'npm start' , it fails to compile and says : ERROR in /home/programoholic/workspace/heroapp/src/app/app.module.ts (3,10): Module '"/home/programoholic/workspace/heroapp/node_modules/@angular/material/material"' has no exported member 'MaterialModule'.

但是当我在做“npm start”时,它不能编译并说:ERROR in /home/programoholic/workspace/heroapp/src/app/app.module。ts(3,10):“模块”/home/programoholic/workspace/heroapp/node_modules/@ angle /material/material”“没有导出的成员“MaterialModule”。

Error Screenshot :

错误截图:

when compiling getting this error

编译时得到这个错误

this is my Package.Json file :

这是我的包。Json文件:

{
  "name": "heroapp",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/cdk": "^2.0.0-beta.11",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/material": "^2.0.0-beta.11",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.2",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/hammerjs": "^2.0.35",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

Please can any body let me know what problem is causing this error ? And what is the best solution for this ? Thanks.

请问有谁能告诉我是什么问题导致了这个错误?最好的解决办法是什么?谢谢。

2 个解决方案

#1


5  

MaterialModule was depreciated in version 2.0.0-beta.3 and it has been removed completely in version 2.0.0-beta.11. See this CHANGELOG for more details. Please go through the breaking changes.

MaterialModule在2.0 -beta版本中被折旧。3 .在2.0 -beta.11版本中已经被完全删除。有关更多细节,请参见此更改日志。请仔细检查这些变化。

MaterialModule has been removed and is no longer available. As noted in the changelog for beta.3, an aggregate module like MaterialModule prevents tools from being able to treeshake unused components and modules.

MaterialModule已经被移除,不再可用。正如在beta的变更日志中所指出的。像MaterialModule这样的聚合模块可以防止工具将未使用的组件和模块用于treeshake。

You need to include individual material component modules in order to use them in your app.

你需要包含单独的材料组件模块,以便在你的应用中使用它们。

#2


1  

Import the individual modules for Angular material like this

导入单个模块的角材料,像这样。

import { matButtonModule,matCardModule,matMenuModule,matToolbarModule,matIconModule,matSelectModule } from '@angular/material';

#1


5  

MaterialModule was depreciated in version 2.0.0-beta.3 and it has been removed completely in version 2.0.0-beta.11. See this CHANGELOG for more details. Please go through the breaking changes.

MaterialModule在2.0 -beta版本中被折旧。3 .在2.0 -beta.11版本中已经被完全删除。有关更多细节,请参见此更改日志。请仔细检查这些变化。

MaterialModule has been removed and is no longer available. As noted in the changelog for beta.3, an aggregate module like MaterialModule prevents tools from being able to treeshake unused components and modules.

MaterialModule已经被移除,不再可用。正如在beta的变更日志中所指出的。像MaterialModule这样的聚合模块可以防止工具将未使用的组件和模块用于treeshake。

You need to include individual material component modules in order to use them in your app.

你需要包含单独的材料组件模块,以便在你的应用中使用它们。

#2


1  

Import the individual modules for Angular material like this

导入单个模块的角材料,像这样。

import { matButtonModule,matCardModule,matMenuModule,matToolbarModule,matIconModule,matSelectModule } from '@angular/material';