Angular 2 agm错误

时间:2018-05-09 10:32:51

标签: angular

我正在尝试在我的角度项目中使用agm 所以我安装了npm install @ agm / core --save 但是当我使用
时 AgmCoreModule.forRoot({       apiKey:'我的api'     }), 这是一个我无法理解的错误:

ERROR in node_modules/@agm/core/services/google-maps-api-wrapper.d.ts(2,10): error TS2305: Module '"C:/Users/Shadi/Documents/development/iot1/node_modules/rxjs/Observable"' has no export
ed member 'Observable'.
node_modules/@agm/core/services/managers/circle-manager.d.ts(2,10): error TS2305: Module '"C:/Users/Shadi/Documents/development/iot1/node_modules/rxjs/Observable"' has no exported member
 'Observable'.
node_modules/@agm/core/services/managers/data-layer-manager.d.ts(2,10): error TS2305: Module '"C:/Users/Shadi/Documents/development/iot1/node_modules/rxjs/Observable"' has no exported me
mber 'Observable'.
node_modules/@agm/core/services/managers/info-window-manager.d.ts(1,10): error TS2305: Module '"C:/Users/Shadi/Documents/development/iot1/node_modules/rxjs/Observable"' has no exported m
ember 'Observable'.
node_modules/@agm/core/services/managers/kml-layer-manager.d.ts(2,10): error TS2305: Module '"C:/Users/Shadi/Documents/development/iot1/node_modules/rxjs/Observable"' has no exported mem
ber 'Observable'.
node_modules/@agm/core/services/managers/marker-manager.d.ts(2,10): error TS2305: Module '"C:/Users/Shadi/Documents/development/iot1/node_modules/rxjs/Observable"' has no exported member
 'Observable'.
node_modules/@agm/core/services/managers/polygon-manager.d.ts(2,10): error TS2305: Module '"C:/Users/Shadi/Documents/development/iot1/node_modules/rxjs/Observable"' has no exported membe
r 'Observable'.
node_modules/@agm/core/services/managers/polyline-manager.d.ts(2,10): error TS2305: Module '"C:/Users/Shadi/Documents/development/iot1/node_modules/rxjs/Observable"' has no exported memb
er 'Observable'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.

这是appModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { FwModule } from '../fw/fw.module';
import { DashboardComponent } from './dashboard/dashboard.component';
import { SettingsComponent } from './settings/settings.component';
import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {appRoutes} from './app.routing';
import { TagsComponent } from './tags/tags.component';
import {DataService} from './shared/data.service';
import {TagsResolverService} from './shared/tags-resolver.service';
import {HttpClientModule} from '@angular/common/http';
import {AgmCoreModule} from '@agm/core';



@NgModule({
  declarations: [
    AppComponent,
    DashboardComponent,
    SettingsComponent,
    TagsComponent
  ],
  imports: [
    BrowserModule,
    FwModule,
    FormsModule,
    RouterModule.forRoot(appRoutes),
    HttpClientModule,
    AgmCoreModule.forRoot({
      apiKey: 'AIzaSyAt1d6t28Sbvaa4exq2dHKOffqUCEGXoqQ'
    }),
  ],
  providers: [
    DataService,
    TagsResolverService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

我删除了node_module并重新安装但出现了同样的错误

1 个答案:

答案 0 :(得分:4)

Agm还没有准备好并与Angular v6和Rxjs v6兼容。要遵循的问题如下:

https://github.com/SebastianM/angular-google-maps/issues/1384

如果你想坚持v6,解决方法是安装Rxjs compat

npm install rxjs-compat --save