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] .
"enhanced-resolve": "3.3.0" fixed the issue for me.
Just saying... if you are using prod build you should be using shrinkwrap... it's there for you guys to use. Also, yarn.
this issue creeped up for me using ngtools/webpack for my angular build... not using angular-cli and I specifically used ngtools/webpack 1.5.3 and the issue resolved itself... with using that other plugin....
So for people using ngtools/webpack simply use at this time version 1.5.3... adding the other package won't do anything no matter what version you use.
upgrading angular/cli to 1.2.4 resolve the problem for me .
Angular apps created with older cli still dont work. To get around it, i just copied a fresh package.json from a new app. If you want to make existing angular app running, (some package among)the following packages(diff i got while getting my own app running) should be upgraded:
diff seodemo/package.json aotdemo/package.json
2c2
< "name": "seodemo",
---
> "name": "aotdemo",
15,23c15,23
< "@angular/animations": "^4.0.0",
< "@angular/common": "^4.0.0",
< "@angular/compiler": "^4.0.0",
< "@angular/core": "^4.0.0",
< "@angular/forms": "^4.0.0",
< "@angular/http": "^4.0.0",
< "@angular/platform-browser": "^4.0.0",
< "@angular/platform-browser-dynamic": "^4.0.0",
< "@angular/router": "^4.4.3",
---
> "@angular/animations": "^4.2.4",
> "@angular/common": "^4.2.4",
> "@angular/compiler": "^4.2.4",
> "@angular/core": "^4.2.4",
> "@angular/forms": "^4.2.4",
> "@angular/http": "^4.2.4",
> "@angular/platform-browser": "^4.2.4",
> "@angular/platform-browser-dynamic": "^4.2.4",
> "@angular/router": "^4.2.4",
25,26c25,26
< "rxjs": "^5.1.0",
< "zone.js": "^0.8.4"
---
> "rxjs": "^5.4.2",
> "zone.js": "^0.8.14"
29,31c29,31
< "@angular/cli": "1.2.0",
< "@angular/compiler-cli": "^4.0.0",
< "@angular/language-service": "^4.0.0",
---
> "@angular/cli": "1.4.3",
> "@angular/compiler-cli": "^4.2.4",
> "@angular/language-service": "^4.2.4",
35c35
< "codelyzer": "~3.0.1",
---
> "codelyzer": "~3.1.1",
45c45
< "ts-node": "~3.0.4",
---
> "ts-node": "~3.2.0",
Should this help someone else:
After reading through this whole thing, I noticed the dependency: "@angular/cli": "1.1.x",
When I allowed that to upgrade, the problem went away.
I am getting the same issue for Angular CLI 1.5.0 I also have Enhanced resolve 3.3.0
Me too. Still getting: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
Even after use Angular CLI 1.5.0 and Enhanced resolve 3.3.0
Same here. Any Update ?
[email protected] is not work for me package.json { "name": "LENDZ", "version": "0.0.1", "author": "Ionic Framework", "homepage": "http://ionicframework.com/", "private": true, "scripts": { "clean": "ionic-app-scripts clean", "build": "ionic-app-scripts build", "lint": "ionic-app-scripts lint", "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve" }, "dependencies": { "@angular/common": "5.0.0", "@angular/compiler": "5.0.0", "@angular/compiler-cli": "5.0.0", "@angular/core": "5.0.0", "@angular/forms": "5.0.0", "@angular/http": "5.0.0", "@angular/platform-browser": "5.0.0", "@angular/platform-browser-dynamic": "5.0.0", "@ionic-native/camera": "^4.4.2", "@ionic-native/core": "4.3.2", "@ionic-native/diagnostic": "^4.5.2", "@ionic-native/facebook": "^4.4.2", "@ionic-native/file": "^4.4.2", "@ionic-native/file-path": "^4.4.2", "@ionic-native/geolocation": "^4.4.2", "@ionic-native/google-maps": "^4.4.2", "@ionic-native/http": "^4.4.2", "@ionic-native/native-storage": "^4.4.2", "@ionic-native/network": "^4.5.2", "@ionic-native/onesignal": "^4.5.2", "@ionic-native/push": "^4.4.2", "@ionic-native/splash-screen": "4.3.2", "@ionic-native/status-bar": "4.3.2", "@ionic-native/stripe": "^4.5.2", "@ionic-native/transfer": "^3.14.0", "@ionic/storage": "^2.1.3", "angular2-moment": "^1.7.0", "cordova-android": "6.3.0", "cordova-browser": "~5.0.1", "cordova-plugin-camera": "^3.0.0", "cordova-plugin-device": "^1.1.4", "cordova-plugin-facebook4": "^1.9.1", "cordova-plugin-file": "^5.0.0", "cordova-plugin-file-transfer": "^1.7.0", "cordova-plugin-filepath": "^1.1.0", "cordova-plugin-geolocation": "^3.0.0", "cordova-plugin-googlemaps": "^2.1.1", "cordova-plugin-inappbrowser": "~1.7.2", "cordova-plugin-ionic-webview": "^1.1.11", "cordova-plugin-nativestorage": "^2.2.2", "cordova-plugin-network-information": "^1.3.4", "cordova-plugin-splashscreen": "^4.0.3", "cordova-plugin-stripe": "^1.5.3", "cordova-plugin-whitelist": "^1.3.1", "cordova-sqlite-storage": "^2.1.2", "cordova.plugins.diagnostic": "^3.7.2", "enhanced-resolve": "^3.4.1", "ionic-angular": "3.9.2", "ionic-plugin-keyboard": "^2.2.1", "ionic2-rating": "^1.2.2", "ionicons": "3.0.0", "onesignal-cordova-plugin": "^2.2.4", "rxjs": "5.5.2", "sw-toolbox": "3.6.0", "zone.js": "0.8.18" }, "devDependencies": { "@ionic/app-scripts": "^3.1.7", "typescript": "2.4.2" }, "description": "An Ionic project", "cordova": { "plugins": { "cordova-plugin-device": {}, "cordova-plugin-ionic-webview": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-whitelist": {}, "ionic-plugin-keyboard": {}, "cordova-plugin-facebook4": { "APP_ID": "xxxxxxxxxxx", "APP_NAME": "LENDZ" }, "cordova-plugin-nativestorage": {}, "cordova-sqlite-storage": {}, "cordova-plugin-camera": {}, "cordova-plugin-file": {}, "cordova-plugin-file-transfer": {}, "cordova-plugin-filepath": {}, "cordova-plugin-googlemaps": { "API_KEY_FOR_ANDROID": "xxxxxxxxxxxxxxxxxxxxxx", "API_KEY_FOR_IOS": "xxxxxxxxxxxxxxxxxxxx" }, "cordova-plugin-geolocation": {}, "onesignal-cordova-plugin": {}, "cordova.plugins.diagnostic": {}, "cordova-plugin-network-information": {}, "cordova-plugin-inappbrowser": {}, "cordova-plugin-stripe": {} }, "platforms": [ "browser", "android" ] } } Please help
As @cbeaujoin well said. If you leave it like this you will build with AOT without troubles.
dependencies
@angular/*:"^4.3.6"
"enhanced-resolve": "3.3.0"
devDependencies
"@angular/cli": "1.2.6"
"typescript": "^2.3.4"
I have to add that typescript had to be 2.3.4 for me, and the best of all, the build time was drastically reduced to around 6:35 when before it was taking about 29min to build. I will stay like this for a while.
[email protected] solved it!
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.