【问题标题】:Cannot find module '@agm/core'找不到模块“@agm/core”
【发布时间】:2017-12-18 07:08:19
【问题描述】:

我正在尝试在我的 Angular 4 应用中使用 Google 地图。
我正在使用 Angular 4 和 Nodejs 8。

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ApplicationRef } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';

import { AgmCoreModule } from '@agm/core';

@NgModule({
  imports: [
    BrowserModule,
    CommonModule,
    FormsModule,
    AgmCoreModule.forRoot({
      apiKey: 'GOOGLEAPIKEY'
    })
  ],
  providers: [],
  declarations: [ AppComponent ],
  bootstrap: [ AppComponent ]
})
export class AppModule {}

请帮帮我??

【问题讨论】:

    标签: javascript angularjs angular google-maps


    【解决方案1】:

    它找不到模块,因为您忘记在导入的 NgModule 中添加它:P:

      imports: [
        BrowserModule
        AgmCoreModule.forRoot({
          apiKey: 'GOOGLEAPIKEY'
        })
      ],
    

    最好的问候;)

    【讨论】:

    • 谢谢,是的,我已经修改了代码。请看一下。但还是同样的错误。
    • 你做了一个:npm install @agm/core --save 吗?
    【解决方案2】:

    npm install @agm/core --save

    这个命令解决了我的问题。非常感谢。

    【讨论】:

      【解决方案3】:

      有同样的问题..只需运行:

      npm uninstall @agm/core -s
      npm install @agm/core -s
      

      【讨论】:

        猜你喜欢
        • 2021-05-08
        • 2019-02-03
        • 1970-01-01
        • 1970-01-01
        • 2018-07-01
        • 2016-09-25
        • 2019-02-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多