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

I'm on windows and adding [email protected] doesn't work for me.

marcscherer avatar Jul 24 '17 14:07 marcscherer

@mscherer82 Did you run npm install? If you did, you can try deleting node_modules and re-running it. It worked for me.

angelnikolov avatar Jul 24 '17 14:07 angelnikolov

@angelnikolov yes, I deleted node_modules and reinstalled all packages.

marcscherer avatar Jul 24 '17 14:07 marcscherer

Hm, can you try running npm ls and see if this is your enhanced-resolve version +-- [email protected]

angelnikolov avatar Jul 24 '17 14:07 angelnikolov

@pvanhemmen You should install enhanced-resolve after npm install. As temporary resolve it's ok. image

eelokets avatar Jul 24 '17 14:07 eelokets

@vicetjs That's what I did and the only way it works for me, too. Thanx for your help!

pvanhemmen avatar Jul 24 '17 14:07 pvanhemmen

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

benelliott avatar Jul 24 '17 14:07 benelliott

@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 avatar Jul 24 '17 14:07 bmcswee

@bmcswee Awesome, thanx for the tip!

pvanhemmen avatar Jul 24 '17 14:07 pvanhemmen

npm listgave me:


+-- @angular/[email protected]
| +-- @ngtools/[email protected]
| +-- @ngtools/[email protected]
| | +-- [email protected]
...
| +-- [email protected]
...
| | +-- [email protected] deduped
...
+-- [email protected]

marcscherer avatar Jul 24 '17 14:07 marcscherer

Installing enhanced-resolve 3.3.0 did the trick thank you!

dgetts192 avatar Jul 24 '17 15:07 dgetts192

[email protected] did the trick for my project. Can somebody please explain me what this package does?

kasperfp avatar Jul 24 '17 15:07 kasperfp

https://github.com/angular/angular-cli/issues/4551 regression from months ago.

jakeNiemiec avatar Jul 24 '17 15:07 jakeNiemiec

@jakeNiemiec This means I should uninstall the package at a later point in time, when the Angular team fixes the bug, right?

Cheers!

kasperfp avatar Jul 24 '17 15:07 kasperfp

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 avatar Jul 24 '17 15:07 andreasonny83

@andreasonny83 did you run exactly this command:

npm i [email protected]

Make sure to update Angular CLI and Node as well.

kasperfp avatar Jul 24 '17 15:07 kasperfp

~~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 avatar Jul 24 '17 15:07 jakeNiemiec

jakeNiemiec comment worked for me too. Is there any fix planned for this breaking change?

mydata avatar Jul 24 '17 15:07 mydata

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 avatar Jul 24 '17 15:07 filipesilva

@filipesilva Worth noting that it is also a direct dependency of @ngtools/webpack.

benelliott avatar Jul 24 '17 16:07 benelliott