angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

AOT build fails

Open adwd opened this issue 9 years ago • 173 comments

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] .

adwd avatar Jul 24 '17 10:07 adwd

no darts, I have been purging yarn.lock and node_modules between builds, to ensure that my CI server will work

mildfuzz avatar Jul 24 '17 20:07 mildfuzz

rm -rf yarn.lock && rm -rf node_modules && yarn install && ng build -prod does not work

rm -rf yarn.lock && rm -rf node_modules && npm i && ng build -prod does work (using npm 5.3.0)

mildfuzz avatar Jul 24 '17 20:07 mildfuzz

Same here: Issue was present on rc.0, seems to be present on rc.1 too.

Removing node_modules, yarn.lock + yarn cache clean, and then re-installing everything from the scratch - doesn't resolve the issue ;/

PS: there's a difference in error message. Content is the same, but on rc.0 it was printed without indents, now it's with nice indentation ;-) as pasted by @mildfuzz

ryzy avatar Jul 24 '17 20:07 ryzy

Tried yarn install as well. It seems it installs correct version 3.3.0 but ng build --prod fails.

Not using yarn in our project, tried just out of curiosity.

sickelap avatar Jul 24 '17 20:07 sickelap

Just tried

npm install -g @angular/cli
ng -v 
 -returns version 1.2.4
npm new aottest
cd aottest
ng build --prod

works without failing no use of yarn or yarn config just npm

Toxicable avatar Jul 24 '17 20:07 Toxicable

@mildfuzz @ryzy what does yarn list enhanced-resolve show you? Also yarn why enhanced-resolve.

filipesilva avatar Jul 24 '17 20:07 filipesilva

@filipesilva

yarn list v0.27.5 └─ [email protected] Done in 1.26s.

thegitty avatar Jul 24 '17 20:07 thegitty

Right, there's definitely something wrong there. We're pinning it to 3.3.0 so yarn shouldn't be installing 3.4.1. Can you run yarn why enhanced-resolve to see why it's resolving to that?

filipesilva avatar Jul 24 '17 20:07 filipesilva

[1/4] Why do we have the module "enhanced-resolve"...? [2/4] Initialising dependency graph... [3/4] Finding dependency... [4/4] Calculating file sizes... info Reasons this module exists

  • "@angular/cli#@ngtools/webpack" depends on it
  • "@angular/cli#webpack" depends on it info Disk size without dependencies: "196kB" info Disk size with unique dependencies: "328kB" info Disk size with transitive dependencies: "820kB" info Number of shared dependencies: 12 Done in 1.61s.

thegitty avatar Jul 24 '17 20:07 thegitty

yarn why enhanced-resolve

Reasons this module exists

  • "awesome-typescript-loader" depends on it
  • "webpack" depends on it

Our deps

"@angular/cli": "1.3.0-rc.0",
"@angular/compiler-cli": "4.1.3",
"@angular/animations": "4.1.3",
"@angular/common": "4.1.3",
"@angular/compiler": "4.1.3",
"@angular/core": "4.1.3",
"@angular/forms": "4.1.3",
"@angular/http": "4.1.3",
"@angular/platform-browser": "4.1.3",
"@angular/platform-browser-dynamic": "4.1.3",
"@angular/platform-server": "4.1.3",
"@angular/router": "4.1.3",
"rxjs": "5.4.2",
"zone.js": "0.8.14"

coryrylan avatar Jul 24 '17 20:07 coryrylan

@thegitty I think you have a linked @angular/cli somewhere... @angular/cli does not depend on enhanced-resolve directly.

@coryrylan hm, I don't see the CLI or ngtools/webpack there.

filipesilva avatar Jul 24 '17 21:07 filipesilva

yarn lock has ngtools/[email protected] angular/[email protected]

coryrylan avatar Jul 24 '17 21:07 coryrylan

version 3.4.1
This module exists because "@angular/cli#@ngtools/webpack" depends on it.

mildfuzz avatar Jul 24 '17 21:07 mildfuzz

Ughh. Build broke for 2nd time in 2 weeks. Adding npm install [email protected] solved the problem.

AdonousTech avatar Jul 24 '17 21:07 AdonousTech

Here is the commit that upgraded webpack

https://github.com/webpack/webpack/commit/16bf0b6f26b23df682433ddefcbff5278a6fac2c

mildfuzz avatar Jul 24 '17 21:07 mildfuzz

I think to force yarn to use a certain version you need to add an entry to resolutions in your package.json

hccampos avatar Jul 24 '17 21:07 hccampos

@coryrylan you need @angular/[email protected] for the fix, but you're in 1.3.0-rc.0.

@mildfuzz that commit does exist but it's not released yet. The last webpack release was 9 days ago, but that commit was 13 hours ago.

I tried copy pasting your package.json and doing yarn, and it seems to install right:

kamik@T460p MINGW64 D:/sandbox/tmp
$ yarn && yarn list enhanced-resolve && yarn why enhanced-resolve
yarn install v0.24.6
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "[email protected]" has unmet peer dependency "@ngrx/store@^2.2.1".
warning "@ngrx/[email protected]" has unmet peer dependency "@ngrx/store@^2.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 66.95s.
yarn list v0.24.6
└─ [email protected]
Done in 0.87s.
yarn why v0.24.6
[1/4] Why do we have the module "enhanced-resolve"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info Reasons this module exists
   - "@angular/cli#@ngtools/webpack" depends on it
   - "@angular/cli#webpack" depends on it
Done in 0.89s.

You might be experiencing a bug in yarn. It wouldn't be the first time it has some trouble resolving versions. I was using v0.24.6 myself.

filipesilva avatar Jul 24 '17 22:07 filipesilva

@filipesilva ahh thanks! I'll give that a try I should of noticed that

coryrylan avatar Jul 24 '17 22:07 coryrylan

@filipesilva that commit appears to be straight onto master with no semver change

mildfuzz avatar Jul 24 '17 22:07 mildfuzz

Yes, but you are not using master, you are using [email protected]. The only way to get master is if you were using it directly from github, which as per your package.json you are not.

filipesilva avatar Jul 24 '17 22:07 filipesilva