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

ng build --prod fail with a message "compiler.compileAll is not a function"

Open morninng opened this issue 9 years ago • 32 comments

Bug Report

When I build with "ng build --prod", following error come out ERROR in this.compiler.compileAll is not a function

Versions.

@angular/cli: 1.1.0 node: 6.9.2 os: linux x64 @angular/common: 4.2.0-rc.2 @angular/compiler: 4.2.0-rc.2 @angular/core: 4.2.0-rc.2 @angular/forms: 4.2.0-rc.2 @angular/http: 4.2.0-rc.2 @angular/platform-browser: 4.2.0-rc.2 @angular/platform-browser-dynamic: 4.2.0-rc.2 @angular/router: 4.2.0-rc.2 @angular/cli: 1.1.0 @angular/compiler-cli: 4.1.3

Repro steps.

(1) ng new (2) adjust package json (3) ng build --prod error happen the repository is here https://github.com/morninng/issue_angularcli

The log given by the failure.

following error comes out

ERROR in this.compiler.compileAll is not a function

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/morninng/development/Angular2/mixidea_cowork/src' @ ./src/main.ts 4:0-74 @ multi ./src/main.ts

Desired functionality.

build should be succeeded

Mention any other details that might be useful.

ng build --dev or ng build works successfully

morninng avatar Jun 07 '17 08:06 morninng

I can't reproduce this on the projects I test. Can you provide a reproduction please?

filipesilva avatar Jun 07 '17 11:06 filipesilva

Hi @filipesilva I have added the reproduce way with repository

(1) ng new (2) adjust package json (3) ng build --prod error happen the repository is here https://github.com/morninng/issue_angularcli

morninng avatar Jun 08 '17 02:06 morninng

Same problem here with angular 4.2.0 release (angular cli 1.1.1 and nodejs 6.10)

ghost avatar Jun 09 '17 13:06 ghost

same issue here, it just started happening few minutes ago, until than all the builds were passing

pgrm avatar Jun 09 '17 13:06 pgrm

I have this problem too after updating npm packages today

mzdunio avatar Jun 09 '17 13:06 mzdunio

I think they changed the flag to -prod only one dash.

rgant avatar Jun 09 '17 13:06 rgant

for me the issue was due to some inconsistencies in my node_modules folder, some libraries probably updated to 4.2 while other were still at 4.1.x - can't reproduce anymore

pgrm avatar Jun 09 '17 15:06 pgrm

I also have this problem. Has there been a fix/work around yet?

garthtee avatar Jun 11 '17 15:06 garthtee

I had the issue too. I don't know exactly what caused it, but this did the trick:

  1. I aligned my package.json dependencies with the default ng-cli package.json. I deleted everything I didn't use anymore, and added everything except the jasmine/karma/protractor packages (I don't have tests yet in this project, maybe some day.... :-)

  2. Delete node_modules and yarn.lock

  3. Reinstall the packages, in my case using yarn. This fixed the problem.

skovmand avatar Jun 12 '17 18:06 skovmand

the same error with @angular 4.2.2 when I do ng build -prod , but not a problem with version 4.1.3

marius-oprea avatar Jun 12 '17 23:06 marius-oprea

I guess --aot option causes this problem. --prod option sets --aot automatically. $ ng build --aot(without --prod) shows the same error.

jun06t avatar Jun 13 '17 02:06 jun06t

Broken by updating to 4.2.2

deleting node_modules does not work for me.

hheexx avatar Jun 13 '17 13:06 hheexx

had to fix @angular/* packages to version 4.1.3 to restore my CI Build

andrelmp avatar Jun 13 '17 18:06 andrelmp

Did some tests, and i think is related to https://github.com/angular/angular/commit/ed73d4f3ac6b542bf5ea3eb73fbe91e2ceabcdb4 Adding "angularCompilerOptions": { "alwaysCompileGeneratedCode": true } to tsconfig.json solved the issue. I don't know if is the correct solution, but works.

andrelmp avatar Jun 13 '17 19:06 andrelmp

This problem is solved after updating angular-cli 1.1.2 in my environment.

$ ng --version
@angular/cli: 1.1.2
node: 8.1.0
os: darwin x64
@angular/common: 4.2.2
@angular/compiler: 4.2.2
@angular/core: 4.2.2
@angular/forms: 4.2.2
@angular/http: 4.2.2
@angular/platform-browser: 4.2.2
@angular/platform-browser-dynamic: 4.2.2
@angular/router: 4.2.2
@angular/cli: 1.1.2
@angular/compiler-cli: 4.2.2

jun06t avatar Jun 16 '17 01:06 jun06t

It also went away for me after updating angular-cli to 1.1.2

eddwin avatar Jun 16 '17 05:06 eddwin

Resolved this error by updating @angular/compiler-cli to 4.2.x. Should work for some.

ColeBeckwith avatar Jun 20 '17 19:06 ColeBeckwith

@ColeBeckwith did you tried update @angular/cli to 1.1.2?

andrelmp avatar Jun 20 '17 20:06 andrelmp

@andrelmp and what if I don't use CLI? This is a breaking change :(

samvloeberghs avatar Jun 20 '17 20:06 samvloeberghs

@samvloeberghs if you don't use cli, you can't use "ng build" command, so isn't related to this issue

andrelmp avatar Jun 20 '17 20:06 andrelmp