AoT not working!
Hey Mark,
AoT compilation stopped working. Now I'm receiving this error when running webpack:
ERROR in ./Client/main.browser.ts
Module not found: Error: Can't resolve './$$_gendir/app/browser-app.module.ngfactory' in '\aspnetcore-angular2-universal-master\Client'
@ ./Client/main.browser.ts 3:0-89
Could you help me with it?
Is this from a fresh project ? Or after adding some components / etc. What errors come up when you do npm run build:AoT it should give some info on where it failed.
It's on fresh project.
npm run build:AoT fails with
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build:aot: `webpack --env.aot --env.client & webpack --env.aot --env.server`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build:aot script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! AppData\Roaming\npm-cache\_logs\2017-07-25T06_35_05_136Z-debug.log
And in build log I have those errors
ERROR in ./Client/main.browser.ts
Module not found: Error: Can't resolve './$$_gendir/app/browser-app.module.ngfactory' in '..\aspnetcore-angular2-universal-master\Client'
@ ./Client/main.browser.ts 3:0-89
ERROR in ./Client/$$_gendir lazy
Module not found: Error: Can't resolve '..\aspnetcore-angular2-universal-master\Client\$$_gendir\app\containers\+lazy\lazy.module.ngfactory.ts' in '..\aspnetcore-angular2-universal-master\Client\$$_gendir'
@ ./Client/$$_gendir lazy
@ ./~/@angular/core/@angular/core.es5.js
@ ./Client/main.browser.ts`
Do you have aspnetcore environment set to production when trying to do AoT builds? Also what version of node and npm are you using?
Yes it was. Node v8.0.0 npm - 5.0.3. I found similar problem here https://github.com/angular/angular-cli/issues/7125. Adding enhanced-resolve: 3.3.0 helped me.
enhanced-resolve: 3.3.0 helped me as well,
the error was on clean clone also on automatic build on visualstudio.vom (2017 hosted)
The issue was introduced with enhanced-resolved that is used by @ngtools/webpack as a dependency by ngtools/webpack. Updating the @ ngtools/webpack: "1.5.3" fixed the issue as they released an emergency fix freezing the internal dependency to [email protected].
More details are here https://github.com/webpack/enhanced-resolve/issues/98
I have the same issue: I updated all packages to the most recent, but, the error that I have is:
ERROR in ./Client/main.browser.ts Module not found: Error: Can't resolve './$$_gendir/app/browser-app.module.ngfactory' in 'S:\EMPREGOS\Core\Universal_Bacon\Angular_File_by_File\Cli ent' @ ./Client/main.browser.ts 3:0-89
and:
ERROR in ./Client/main.server.aot.ts Module not found: Error: Can't resolve './ngfactory/app/server-app.module.ngfactory' in 'S:\EMPREGOS\Core\Universal_Bacon\Angular_File_by_File\Clie nt' @ ./Client/main.server.aot.ts 6:0-87
and:
npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! [email protected] build:aot:
webpack --env.aot --env.client & webpack --env.aot --env.servernpm ERR! Exit status 2 npm ERR! npm ERR! Failed at the [email protected] build:aot script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\daniel.cb\AppData\Roaming\npm-cache_logs\2017-07-25T20_36_49_570Z-debug.log
I send you a copy of my project. Could you see if is a framework problem or package version problem?
Hi,
try add "enhanced-resolved" : "3.3.0" to devDependencies, normaly this package fix the problem.
Note: On computer with npm5 the error still with this fix :( I don't have found how to fix with npm 5
This will be cleaned up in the latest PR #376
@Samkovskyi
But all you need to do is remove include: /Client from your .ts$ module rules in webpack.