Angular 5 production build throwing error

2019-02-13 20:42发布

问题:

I have an angular app using version 5.2 which is throwing the following error when building for production (does not throw the error when running the app locally or running a standard build.)

ERROR in Either route or analyzedModules has to be specified!

Upon research the error is thrown by the ahead of time compiler but I'm not sure what could be causing it, if anyone has suggestions of where to look that would be greatly appreciated.

Edit: As requested here is the error stack
ng build --prod

Date: 2018-05-17T10:23:10.379Z Hash: a96f44ca3fbe47707a02 Time: 10740ms chunk {0} runtime.6afe30102d8fe7337431.js (runtime) 1.05 kB [entry] [rendered] chunk {1} styles.5283ab92ad436ab9264c.css (styles) 116 kB [initial] [rendered] chunk {2} polyfills.bb453547f4804812c2d3.js (polyfills) 130 bytes [initial] [rendered] chunk {3} main.324541d43b39aaa6d019.js (main) 128 bytes [initial] [rendered]

ERROR in Either route or analyzedModules has to be specified!

回答1:

I realised I was using version 6.0.1 of the Angular Compiler CLI with an Angular 5.2 app. I reverted the version of the Compiler CLI to 5.2.11 and the issue is resolved.