AOT build fails
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.2.3
node: 6.11.1
os: darwin x64
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.2.3
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1
Repro steps.
$ ng new hello
$ cd hello
$ ng build --prod
The log given by the failure.
$ ng build --prod
Hash: edf6fb3ccb1b82fa940c
Time: 10775ms
chunk {0} polyfills.71b130084c52939ca448.bundle.js (polyfills) 177 kB {4} [initial] [rendered]
chunk {1} main.e81f19d3f6b27a436c79.bundle.js (main) 1.09 kB {3} [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk {3} vendor.f7457d5ac1e9743fd76f.bundle.js (vendor) 849 kB [initial] [rendered]
chunk {4} inline.18e445e37a0efd4dcfa2.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'hello/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts
Desired functionality.
aot build runs
Mention any other details that might be useful.
Maybe, enhanced-resolve 3.4.0 is cause. https://github.com/webpack/enhanced-resolve/issues/98
ng build --prod runs successfully after npm i [email protected] .
I'm on windows and adding [email protected] doesn't work for me.
@mscherer82 Did you run npm install? If you did, you can try deleting node_modules and re-running it. It worked for me.
@angelnikolov yes, I deleted node_modules and reinstalled all packages.
Hm, can you try running npm ls and see if this is your enhanced-resolve version
+-- [email protected]
@pvanhemmen
You should install enhanced-resolve after npm install. As temporary resolve it's ok.

@vicetjs That's what I did and the only way it works for me, too. Thanx for your help!
In order to make my build server happy I forked angular/ngtools-webpack-builds and pinned enhanced-resolve at 3.3.0, then forked angular/cli-builds to point it at my ngtools fork. If anyone is interested they can try it out by changing their package.json to "@angular/cli": "github:benelliott/cli-builds#24a8837" (note however that both libraries will be at master, not a specific version).
@pvanhemmen I was able to get deployment via fresh install working again by using npm shrinkwrap after installing [email protected]. This got my Jenkins build pipeline working fine again
This should also prevent upstream dependency breakage from harming my project in the future :)
@bmcswee Awesome, thanx for the tip!
npm listgave me:
+-- @angular/[email protected]
| +-- @ngtools/[email protected]
| +-- @ngtools/[email protected]
| | +-- [email protected]
...
| +-- [email protected]
...
| | +-- [email protected] deduped
...
+-- [email protected]
Installing enhanced-resolve 3.3.0 did the trick thank you!
[email protected] did the trick for my project. Can somebody please explain me what this package does?
https://github.com/angular/angular-cli/issues/4551 regression from months ago.
@jakeNiemiec This means I should uninstall the package at a later point in time, when the Angular team fixes the bug, right?
Cheers!
Guys, the [email protected] way-around doesn't work on my project. I still have the same error. Is there any update on this issue?
@andreasonny83 did you run exactly this command:
npm i [email protected]
Make sure to update Angular CLI and Node as well.
~~Just to be clear (@kasperfp, @andreasonny83):~~
~~❌ Won't work (this is what npm@^5 put in my package.json when I ran npm i [email protected]):~~
~~"enhanced-resolve": "^3.3.0",~~
~~✅ Will Work:~~
~~"enhanced-resolve": "3.3.0",~~
See more complete comment by @Gustorn below: https://github.com/angular/angular-cli/issues/7113#issuecomment-317483817
jakeNiemiec comment worked for me too. Is there any fix planned for this breaking change?
Hi all,
This seems to be a bug/breaking change in enhanced-resolve, a dependency of webpack. Will try to talk to the Webpack maintainers about this.
Meanwhile pin it to "enhance-resolve": "3.3.0" in your package.json.
Edit: issue on enhanced-resolve is https://github.com/webpack/enhanced-resolve/issues/98.
@filipesilva Worth noting that it is also a direct dependency of @ngtools/webpack.