Search code examples
angularangular2-cli

"Error: AccountRoutingModule is not an NgModule"


Upgrading my Angular 2.2.3 application from Angular CLI 2.0.0-beta.21 to Angular CLI 2.0.0-beta.22-1, my ng build now fails with:

Error: AccountRoutingModule is not an NgModule
    at AotPlugin.getNgModuleMetadata (/home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/plugin.js:332:19)
    at /home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/plugin.js:345:51
    at Array.map (native)
    at AotPlugin.extractLoadChildren (/home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/plugin.js:343:14)
    at /home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/plugin.js:346:30
    at Array.map (native)
    at AotPlugin.extractLoadChildren (/home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/plugin.js:343:14)
    at AotPlugin._processNgModule (/home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/plugin.js:272:38)
    at /home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/plugin.js:242:39
    at process._tickCallback (internal/process/next_tick.js:103:7)

The application built and ran fine with Angular CLI 2.0.0-beta.21; however, Angular CLI 2.0.0-beta.22-1 now uses AoT by default instead of JiT.


Solution

  • Change the AccountRoutingModule from:

    import { ModuleWithProviders } from '@angular/core';
    

    to:

    import { NgModule } from '@angular/core';