1

我正在尝试在我的角度项目中使用 agm 所以我安装了 npm install @agm/core --save 但是当我使用
AgmCoreModule.forRoot({ apiKey: 'my 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 exported 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 并再次安装,但出现同样的错误

4

1 回答 1

3

Agm 尚未准备好并与 Angular v6 和 Rxjs v6 兼容。接下来的问题如下:

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

如果您想坚持使用 v6,解决方法是也安装 Rxjs compat

npm install rxjs-compat --save
于 2018-05-09T14:10:42.503 回答