簡體   English   中英

找不到模塊'@ agm / core'

[英]Cannot find module '@agm/core'

我正試圖在我的角度4應用程序中使用谷歌地圖。
我正在使用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 {}

請幫我 ??

npm install @ agm / core --save

這個命令解決了我的問題。謝謝了很多。

有同樣的問題..運行:

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

它無法找到該模塊,因為您忘記在導入中的NgModule中添加它:P:

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

最好的祝福 ;)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM