简体   繁体   中英

Cannot find module '@agm/core'

I am trying to use Google maps in my angular 4 app.
I am using Angular 4 and 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 {}

Please help me ??

npm install @agm/core --save

This command solved my problem.Thanks a lot.

Had the same issue.. Just run :

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

It cannot find the module because you forgot to add it in your NgModule in imports :P :

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

Best regards ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM