aspnetcore-angular-universal icon indicating copy to clipboard operation
aspnetcore-angular-universal copied to clipboard

AoT not working!

Open taras-samkvoskyi opened this issue 9 years ago • 9 comments

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?

taras-samkvoskyi avatar Jul 24 '17 17:07 taras-samkvoskyi

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.

MarkPieszak avatar Jul 24 '17 18:07 MarkPieszak

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`

taras-samkvoskyi avatar Jul 25 '17 06:07 taras-samkvoskyi

Do you have aspnetcore environment set to production when trying to do AoT builds? Also what version of node and npm are you using?

MarkPieszak avatar Jul 25 '17 09:07 MarkPieszak

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.

taras-samkvoskyi avatar Jul 25 '17 09:07 taras-samkvoskyi

enhanced-resolve: 3.3.0 helped me as well,

the error was on clean clone also on automatic build on visualstudio.vom (2017 hosted)

TommyKolodziejczyk avatar Jul 25 '17 10:07 TommyKolodziejczyk

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

markoj21 avatar Jul 25 '17 15:07 markoj21

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.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! 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?

Angular_File_by_File.zip

borgotecnologia avatar Jul 25 '17 20:07 borgotecnologia

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

Crazyht avatar Jul 27 '17 08:07 Crazyht

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.

MarkPieszak avatar Aug 19 '17 03:08 MarkPieszak