问题
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.
回答1:
A similar error happened to me when I changed this line in the devDependencies section of package.json :
"typescript": "~2.0.0", to "typescript": "~2.1.4",
in an attempt to use the latest (at the time) edition of TypeScript.
When I "dialed it back a bit" to this: "typescript": "~2.0.10",
the error went away.
I hope this helps.
回答2:
Change the AccountRoutingModule
from:
import { ModuleWithProviders } from '@angular/core';
to:
import { NgModule } from '@angular/core';
来源:https://stackoverflow.com/questions/41108456/error-accountroutingmodule-is-not-an-ngmodule