Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
morninng opened this issue Jun 7, 2017 · 32 comments
Closed
Assignees
Labels
effort1: easy (hours) help wanted P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken

Comments

@morninng
Copy link

morninng commented Jun 7, 2017

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

@filipesilva
Copy link
Contributor

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

@filipesilva filipesilva self-assigned this Jun 7, 2017
@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Jun 7, 2017
@morninng
Copy link
Author

morninng commented Jun 8, 2017

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

@ghost
Copy link

ghost commented Jun 9, 2017

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

@pgrm
Copy link

pgrm commented Jun 9, 2017

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

@mzdunio
Copy link

mzdunio commented Jun 9, 2017

I have this problem too after updating npm packages today

@rgant
Copy link

rgant commented Jun 9, 2017

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

@pgrm
Copy link

pgrm commented Jun 9, 2017

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

@garthtee
Copy link

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

@filipesilva filipesilva added command: build help wanted effort1: easy (hours) severity3: broken P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful and removed needs: repro steps We cannot reproduce the issue with the information given labels Jun 12, 2017
@skovmand
Copy link

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.

@marius-oprea
Copy link

marius-oprea commented Jun 12, 2017

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

@jun06t
Copy link

jun06t commented Jun 13, 2017

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

@hheexx
Copy link

hheexx commented Jun 13, 2017

Broken by updating to 4.2.2

deleting node_modules does not work for me.

@andrelmp
Copy link
Contributor

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

@andrelmp
Copy link
Contributor

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

@jun06t
Copy link

jun06t commented Jun 16, 2017

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

@eddwin
Copy link

eddwin commented Jun 16, 2017

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

@ColeBeckwith
Copy link

ColeBeckwith commented Jun 20, 2017

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

@andrelmp
Copy link
Contributor

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

@samvloeberghs
Copy link

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

@andrelmp
Copy link
Contributor

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

@samvloeberghs
Copy link

samvloeberghs commented Jun 20, 2017

@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
Copy link

samvloeberghs commented Jun 20, 2017

@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

@soerenbf
Copy link

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.

@jeffreys-cat
Copy link

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

@jsessink
Copy link

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

@filipesilva
Copy link
Contributor

This seemed to be caused by a mismatch between @angular/* packages and is solved by upgrading to 4.2.4+. #6817 will also set that minimum for new apps.

@nicolae536
Copy link

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

@chelaruc
Copy link

chelaruc commented Aug 4, 2017

Me too :(

@atifsaddique211f
Copy link

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

@sasanazizi
Copy link

sasanazizi commented Sep 26, 2017

@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

@atariman5000
Copy link

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.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: easy (hours) help wanted P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken
Projects
None yet
Development

No branches or pull requests