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

@andrelmp I have the impression the issue is not related specifically to the "ng-build" command or cli in general.. it's related to the upgrade from 4.1.x to 4.2.X. I'm not using cli, and I have the same issue updating from 4.1 to 4.2. Even the same error message mentioned before: this.compiler.compileAll

samvloeberghs avatar Jun 20 '17 20:06 samvloeberghs

@andreImp @ColeBeckwith specifing the compiler-cli 4.2.3 resolved it for me. Why did I mention breaking change: I did not need it on 4.1.3, so I consider it to be one

samvloeberghs avatar Jun 20 '17 20:06 samvloeberghs

For me, the issue was my node version (8.1.2). If you use nvm to control your node environment, try downgrading to 7.x.x (i had 7.4.0 installed). This solved the issue for me.

soerenbf avatar Jun 21 '17 14:06 soerenbf

update @angular/compiler-cli to 4.2.4 & @angular/cli to 1.1.3 resolved this error for me.

jeffreys-cat avatar Jun 26 '17 01:06 jeffreys-cat

Just wanted to point out that downgrading is unnecessary. I was running into this issue as well with the aot flag, and have resolved it by:

  • Updating NodeJS from 8.0.0 to 8.1.2
  • Updating NPM from 5.0.3 to 5.0.4
  • rm -rf on node_modules
  • npm cache verify
  • Set package versions: All @angular/* packages are at 4.2.4 @angular/cli is at 1.1.3
  • npm i

Verify that your packages are valid in your directory (do an npm list --depth=0).

I also removed my package-lock.json, since I was starting fresh, but not sure if necessary (as it should update that file with changes to the package.json and running npm i).

jsessink avatar Jun 27 '17 15:06 jsessink

This seemed to be caused by a mismatch between @angular/* packages and is solved by upgrading to 4.2.4+. https://github.com/angular/angular-cli/pull/6817 will also set that minimum for new apps.

filipesilva avatar Jun 28 '17 13:06 filipesilva

Anyone getting this ? I still get it using @ngtools/webpack

nicolae536 avatar Jul 29 '17 22:07 nicolae536

Me too :(

chelaruc avatar Aug 04 '17 09:08 chelaruc

Resolved this error by updating @angular/compiler-cli to 4.2.3

atifsaddique211f avatar Aug 17 '17 07:08 atifsaddique211f

@filipesilva I update @angular/compiler-cli to 4.4.3 but not resolved ! environments : @angular/cli: 1.2.7 node: 7.8.0 os: win32 x64 @angular/animations: 4.3.3 @angular/common: 4.3.3 @angular/compiler: 4.3.3 @angular/core: 4.3.3 @angular/forms: 4.3.3 @angular/http: 4.3.3 @angular/platform-browser: 4.3.3 @angular/platform-browser-dynamic: 4.3.3 @angular/platform-server: 4.3.3 @angular/router: 4.3.3 @angular/cli: 1.2.7 @angular/compiler-cli: 4.4.3

sasanazizi avatar Sep 26 '17 10:09 sasanazizi

I am using ASP.NET Core 2.0's Angular template and upgraded from Angular 4 to Angular 5. I replaced two instances of AotPlugin in my wepack.config.js file with AngularCompilerPlugin to fix this problem. I can't recall where I got the link from now, but anyone looking to do the same can go (https://long2know.com/2017/11/angular-5-0-released/) to see how it is done.

atariman5000 avatar Dec 21 '17 12:12 atariman5000

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.