angular-google-maps: AgmCoreModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy

I’ve been trying to setup AGM in my project today, but nothing works. Up to Angular 10.1.2 this error is present and updating helps.

But on every version up to the latest one, whenever I import AgmCoreModule in the app.module.ts I get this error:

  ERROR in node_modules/@agm/core/lib/core.module.d.ts:25:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
    
    This likely means that the library (@agm/core/lib/core.module) which declares AgmCoreModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
    
    25 export declare class AgmCoreModule {

I installed it using:

npm install @agm/core --save
npm install @types/googlemaps@3.39.12 --save-dev

to avoid the type errors in the newest @types/googlemaps version.

My current ng version is:

Angular CLI: 10.1.7
Node: 12.5.0
OS: darwin x64

Angular: 10.1.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1001.7
@angular-devkit/build-angular   0.1001.7
@angular-devkit/core            10.1.7
@angular-devkit/schematics      10.1.7
@angular/cdk                    9.2.4
@angular/cli                    10.1.7
@angular/material               9.2.4
@schematics/angular             10.1.7
@schematics/update              0.1001.7
rxjs                            6.6.3
typescript                      3.9.7

and this is my app.module.ts:

import { AgmCoreModule } from '@agm/core/lib/core.module';
  imports: [
    BrowserAnimationsModule,
    AgmCoreModule.forRoot({
      apiKey: 'YOUR-API-KEY-HERE',
      libraries: ['places'],
    }),
  ],

I’ve ran out of ideas. Can someone please help?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 15

Most upvoted comments

i had the same issue but i was able to resolve with this “npm install @agm/core@1”, i hope this helps.

It was Visual Studio Code automatically adding the wrong import…

what it added: import { AgmCoreModule } from '@agm/core/lib/core.module';

what it should be: import { AgmCoreModule } from '@agm/core';

I have the same problem with Angular 15

This isn’t easilly solveable.

The package isn’t built for ivy and isn’t even builtl following modern angular library standards.

It uses ng-packagr to build the library, modern angular libraries use ng-build and add ivysupport on build.

The reason it’s broken since Angular 15 is that enableIvy has been deprecated as Ivy is now angular’s only rendering engine. See this link of upgrade notes for more info.

https://angular.io/guide/update-to-version-15

This package needs ripping apart and putting into a modern framework where public-api.ts is used and a proper build process takes place. Currently don’t have time to do this, but will revisit in 2 months. If not solved by then i’ll release a new library.

I have the same problem with Angular 15

did you solve it??

i had the same issue but i was able to resolve with this “npm install @agm/core@1”, i hope this helps.

Thanks this solved my problem 😉

I’d faced similar problem few days ago. I solved it by adding the following script inside my “package.json” file.

“scripts”: { “postinstall”: “ngcc” } Save and rebuild the application.

i am having the same problem import { AgmCoreModule } from '@agm/core';

imports: [ BrowserModule, AppRoutingModule, AgmCoreModule.forRoot({apiKey:''}), ], has anyone solved it already?

I’m getting the same errors in the line
import { AgmCoreModule } from '@agm/core';