我正在尝试编译我的Angular 4项目。我已经按照" https://material.angular.io/guide/getting-started"安装了角度材料。并在app.module.ts中包含依赖项。当我尝试编译项目时,我收到了下面提到的警告和错误:
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/rxjs/Subject.d.ts (16,22): Class 'Subject<T>' incorrectly e
xtends base class 'Observable<T>'.
Types of property 'lift' are incompatible.
Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<
R>'.
Type 'Observable<T>' is not assignable to type 'Observable<R>'.
Type 'T' is not assignable to type 'R'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/bidi/index.d.ts (8,10): Modu
le '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Directionality'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/bidi/index.d.ts (8,26): Modu
le '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'DIRECTIONALITY_PROVI
DER'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/bidi/index.d.ts (8,51): Modu
le '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'DIR_DOCUMENT'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/bidi/index.d.ts (8,65): Modu
le '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Direction'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/bidi/index.d.ts (8,76): Modu
le '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Dir'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/bidi/index.d.ts (8,81): Modu
le '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'BidiModule'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/portal.d.ts (8,10): M
odule '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Portal'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/portal.d.ts (8,18): M
odule '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'PortalHost'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/portal.d.ts (8,30): M
odule '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'BasePortalHost'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/portal.d.ts (8,46): M
odule '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'ComponentPortal'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/portal.d.ts (8,63): M
odule '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'TemplatePortal'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/portal-directives.d.t
s (8,10): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Templa
tePortalDirective'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/portal-directives.d.t
s (8,35): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Portal
HostDirective'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/portal-directives.d.t
s (8,56): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Portal
Module'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/portal/dom-portal-host.d.ts
(8,10): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'DomPorta
lHost'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/platform/platform.d.ts (8,10
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Platform'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/platform/features.d.ts (8,10
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'getSupportedI
nputTypes'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/platform/index.d.ts (8,10):
Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'PlatformModule'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/live-announcer.d.ts (8,
10): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'AriaLivePol
iteness'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/live-announcer.d.ts (8,
30): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'LIVE_ANNOUN
CER_ELEMENT_TOKEN'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/live-announcer.d.ts (8,
60): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'LiveAnnounc
er'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/live-announcer.d.ts (8,
75): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'LIVE_ANNOUN
CER_PROVIDER_FACTORY'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/live-announcer.d.ts (8,
108): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'LIVE_ANNOU
NCER_PROVIDER'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/focus-trap.d.ts (8,10):
Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'FocusTrap'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/focus-trap.d.ts (8,21):
Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'FocusTrapFactor
y'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/focus-trap.d.ts (8,39):
Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'FocusTrapDeprec
atedDirective'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/focus-trap.d.ts (8,69):
Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'FocusTrapDirect
ive'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/interactivity-checker.d
.ts (8,10): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'Inte
ractivityChecker'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/fake-mousedown.d.ts (8,
10): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'isFakeMouse
downFromScreenReader'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/index.d.ts (8,10): Modu
le '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'A11yModule'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,10
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'UP_ARROW'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,20
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'DOWN_ARROW'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,32
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'RIGHT_ARROW'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,45
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'LEFT_ARROW'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,57
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'PAGE_UP'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,66
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'PAGE_DOWN'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,77
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'HOME'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,83
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'END'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,88
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'ENTER'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,95
): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'SPACE'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,10
2): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'TAB'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,10
7): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'ESCAPE'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,11
5): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'BACKSPACE'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/keyboard/keycodes.d.ts (8,12
6): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'DELETE'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/core.d.ts (1,10): Module '"C
:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'coerceBooleanProperty'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/core.d.ts (1,33): Module '"C
:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'coerceNumberProperty'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/core.d.ts (1,55): Module '"C
:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'ObserveContentModule'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/core.d.ts (1,77): Module '"C
:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'ObserveContent'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/list-key-manager.d.ts (
8,10): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'CanDisabl
e'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/core/a11y/list-key-manager.d.ts (
8,22): Module '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'ListKeyMa
nager'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/sort/sort-header.d.ts (11,10): Mo
dule '"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'CdkColumnDef'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/table/cell.d.ts (9,10): Module '"
C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'CdkCell'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/table/cell.d.ts (9,19): Module '"
C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'CdkColumnDef'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/table/cell.d.ts (9,33): Module '"
C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'CdkHeaderCell'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/table/table.d.ts (1,10): Module '
"C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'CdkTable'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/table/row.d.ts (1,10): Module '"C
:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'CdkHeaderRow'.
ERROR in C:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/material/typings/table/row.d.ts (1,24): Module '"C
:/Users/narayanans/Desktop/MEAN-project/client/node_modules/@angular/cdk/cdk"' has no exported member 'CdkRow'.
ERROR in BidiModule is not an NgModule
我的Package.JSON如下所示:
{
"name": "client",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.3.6",
"@angular/cdk": "github:angular/cdk-builds",
"@angular/cli": "^1.3.2",
"@angular/common": "^4.3.6",
"@angular/compiler": "^4.3.6",
"@angular/compiler-cli": "^4.3.6",
"@angular/core": "^4.3.6",
"@angular/forms": "^4.3.6",
"@angular/http": "^4.3.6",
"@angular/material": "^2.0.0-beta.8",
"@angular/platform-browser": "^4.3.6",
"@angular/platform-browser-dynamic": "^4.3.6",
"@angular/platform-server": "^4.3.6",
"@angular/router": "^4.3.6",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"latest-version": "^3.1.0",
"ng2-materialize": "^1.3.2",
"popper.js": "^1.12.3",
"rxjs": "^6.0.0-alpha.0",
"ts-helpers": "^1.1.1",
"typescript": "^2.4.2",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0"
}
}
这就是app.module.ts的样子:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { RouterModule } from "@angular/router";
import { NavbarComponent } from './components/navbar/navbar.component';
import { HomeComponent } from './components/home/home.component';
import { DashboardComponent } from './components/dashboard/dashboard.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
// import { MaterialModule } from '@angular/material';
import { MdButtonModule, MdCardModule, MdMenuModule, MdToolbarModule, MdIconModule } from '@angular/material';
import 'hammerjs';
@NgModule({
declarations: [
AppComponent,
NavbarComponent,
HomeComponent,
DashboardComponent,
],
imports: [
BrowserModule,
HttpModule,
ReactiveFormsModule,
FormsModule,
AppRoutingModule,
BrowserAnimationsModule,MdButtonModule,
MdMenuModule,
MdCardModule,
MdToolbarModule,
MdIconModule
// MdInputModule,
// MdButtonModule,
// RouterModule.forRoot([
// {path:'home', component:HomeComponent},
// {path:'dashboard', component:DashboardComponent}
// ])
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
答案 0 :(得分:1)
我遇到了这个问题 - 我还在寻找答案。
此外,上述最新评论(8月29日)声明不要将cdk-builds与最新材料混合 - 该声明与材料网站本身存在直接冲突。安装说明声明包括:
https://material.angular.io/guide/getting-started
npm install --save angular/material2-builds angular/cdk-builds
请说明我们应该偏离材料团队明确说明的原因。
由于
答案 1 :(得分:1)
我遇到了这个问题,我尝试安装@ angular / cdk和@ angular / material作为相同的版本。问题已解决。
答案 2 :(得分:0)
import {MatCheckboxModule,MatAutocompleteModule, MatSlideToggleModule,MatButtonModule,MatFormFieldControl, MatIconModule,MatInputModule,MatSelectModule,MatSortModule, 来自'@ angular / material'的MatDatepickerModule,DateAdapter,MatChipsModule};
答案 3 :(得分:0)
在Windows中安装Angular 4
或者您可以转到此URL并找到安装RC.1然后复制命令 https://github.com/angular/angular/blob/master/CHANGELOG.md
如果没有,请确保您有Typescript 2.1.6或更高版本,然后使用此命令更新打字稿:npm install typescript@2.2.1 --save
然后再使用此cmmand检查角度版本:ng -v将显示角度版本4