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

New version of cli `ng build --prod` gives error.

Open webcat12345 opened this issue 9 years ago • 38 comments

Bug Report

- [X] bug report
- [ ] feature request

Versions.

Output from: ng --version.

@angular/cli: 1.0.0-rc.2
node: 7.6.0
os: linux x64
@angular/cli: 1.0.0-rc.2
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/router: 3.4.10

Repro steps.

Nothing changed. Problem is happening after upgrading CLI version to rc.2.

I read the issue https://github.com/angular/angular-cli/issues/5623 , but it is closed without any solution. It is nearly impossible to change all properties to public, because project is too big.

I tried to change, but I gave up now.

Strange thing is build on Github through Codeship is succeed. How is it possible? And why not on local?

The log given by the failure.

ERROR in /home/rango/Desktop/test/accepter/ng-reason/src/$$_gendir/app/components/home/home.component.ngfactory.ts (1038,49): Property 'test_detail_mode' is private and only accessible within class 'HomeComponent'.
/home/rango/Desktop/test/accepter/ng-reason/src/$$_gendir/app/components/home/home.component.ngfactory.ts (1041,44): Property 'test_detail_mode' is private and only accessible within class 'HomeComponent'.

ERROR in /home/rango/Desktop/test/accepter/ng-reason/src/$$_gendir/app/components/reason/reason.component.ngfactory.ts (1230,44): Property 'hours' is private and only accessible within class 'ReasonComponent'.
/home/rango/Desktop/test/accepter/ng-reason/src/$$_gendir/app/components/reason/reason.component.ngfactory.ts (1234,50): Property 'statistic' is private and only accessible within class 'ReasonComponent'.
... ... ...

Desired functionality.

Is there anyway to upgrade codebase without changing all issues by manually? Migrating all issues line by line is too pain for us, also creating getter, setter is same for us.

Mention any other details that might be useful.

I think if this error is too critical then CLI should gives error on ng serve or ng build.

Thank you very much.

webcat12345 avatar Mar 29 '17 14:03 webcat12345

Hi, I had the same issue. It's related to AoT. Follow this tips to get everything working again: https://github.com/qdouble/angular-webpack2-starter#aot--donts

thezeronine avatar Mar 30 '17 17:03 thezeronine

Hi, Thanks @TheZeroNine I had also the same issue. But it only appears on 'ng build --prod --aot' and not on 'ng serve'. Is it possible to see these error before starting a build. (don't want to start build after every change -.-)

JosuaMeier avatar Mar 31 '17 08:03 JosuaMeier

I have these after upgrading form angular cli beta into version 1.0. the sad part is my project is too big to handle this :(

doyevaristo avatar Mar 31 '17 12:03 doyevaristo

Hi, I had the same issue when running ng build --aot --prod -sm false. TerminalListComponent.ngfactory.ts (10181,35): Supplied parameters do not match any signature of call target. And I can't find the ngfactory.ts file ,so i don't know how to solve it . so sad ...

` $ng --version

@angular/cli: 1.0.0 node: 7.2.0 os: darwin x64 @angular/common: 2.4.10 @angular/compiler: 2.4.10 @angular/core: 2.4.10 @angular/forms: 2.4.10 @angular/http: 2.4.10 @angular/platform-browser: 2.4.10 @angular/platform-browser-dynamic: 2.4.10 @angular/router: 3.4.10 @angular/cli: 1.0.0 @angular/compiler-cli: 2.4.10

`

ginkosen avatar Apr 03 '17 09:04 ginkosen

@ginkosen
Check TerminalListComponent, then you can see this kind of issue.

HTML : 
<element (click)="customfn(a, b)"></element>

Typescript : 
public customfn(param:any):void {
...
}

As you can see Supplied parameters do not match any signature of call target.

webcat12345 avatar Apr 03 '17 09:04 webcat12345

I also can't find the ngfactory files after build errors. If I had them, it would be much easier to debug... (using @angular/cli version 1.0.0, @angular/* version 2.4.10, and typescript version 2.0.2)

ophirbushi avatar Apr 06 '17 10:04 ophirbushi

I am having this issue as well. Is there a way to find that ngfactory file? Also, it would be great if the error message could show the name of the call target or something similar to identify the offending method

dhilgarth avatar Apr 11 '17 09:04 dhilgarth

@webcat12345 Thx , I check my code again , and i find the problem and slove.

ginkosen avatar Apr 12 '17 03:04 ginkosen

Problem is some npm packages are having same issues. They should be upgraded to latest angular and angular/cli version since we are using Angular4 and angular/cli 1.0.0.

webcat12345 avatar Apr 12 '17 03:04 webcat12345

why ng serve and ng build (without --prod option) are OK ?!!!!!

da45 avatar Apr 18 '17 14:04 da45

make the property hours,test_detail_mode,statistic public.

doyevaristo avatar Apr 19 '17 05:04 doyevaristo

I am having issues with ng build and ng serve when AOT is enabled.

The errors are along the lines of: $$_gendir/node_modules/.../XYZ.ngfactory.ts (1,1): Cannot find module 'XYZ'.

and

ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts
Module not found: Error: Can't resolve 'XYZ' in '/.../demo/src/$$_gendir/app'
 @ ./src/$$_gendir/app/app.module.ngfactory.ts 24:0-37
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:3000 ./src/main.ts

Typescript compiles cleanly, I have looked at the "don'ts" page. It also works perfectly in either build or serve with --aot false.

A lot of other people seem to be having similar issues: https://github.com/angular/angular-cli/issues/6020 https://github.com/angular/angular-cli/issues/6013 https://github.com/angular/angular-cli/issues/5802 https://github.com/angular/angular-cli/issues/5779 https://github.com/angular/angular-cli/issues/5765

If we could get a better error message, or have the option of saving the files somewhere to inspect maybe it would be a little less opaque.

tlong-dev avatar Apr 20 '17 20:04 tlong-dev

I hope this is of help to someone out there, wondering why their recently updated angular4(...but only moments ago, angular2) project won't build without throwing this decipherable message _"ERROR in /Users/me/Desktop/kodotest/src/$$gendir/app/app.component.ngfactory.ts (4352,35): Supplied parameters do not match any signature of call target."

Aha...ok...thanks for that! What ever could you mean?...First of all, I don't own a factory...ahem! Ok, enough jibbering...DO THIS!(I'm on a Mac.Not sure if Terminal prompts are identical on Windows.)

  1. In Terminal execute: "npm install -g angular-cli-ghpages"
  2. In your app's 'package.json', add the line: "deploy": "ng build -sm -ec -bh /aboutme/ & ngh --silent=false",
  3. Finally, in Terminal execute: "npm run deploy"

Strangely enough, I still get an error.....(error: unknown option `--silent' ) but IT STILL BUILDS! And outputs my dist folder...

Hope this saves someone an hour.

mensahGit avatar Apr 22 '17 02:04 mensahGit

I love the CLI, guys!

Can you write the generated files in $$_gendir to disk, so that AoT users can debug?

--edit: this is actually a webpack-related question.

When AoT compilation files, one can read the source files in browser with:

http://localhost:4200/src/app/app.component.ts :arrow_right: HTTP 200

but the generated files are not: http://localhost:4200/src/$$_gendir/app/app.component.ngfactory.ts :arrow_right: HTTP 404

dherges avatar Apr 26 '17 07:04 dherges

same problem with cli 1.0.0, but I downgrade to 1.0.0-rc4 and it works without errors.

LeonardoX77 avatar Apr 26 '17 08:04 LeonardoX77

So just wanted to add my 2cents (australian, not sure how much that is US).

We were struggling with these problems and it is I think not reasonable for ng serve to work and then have build issues but I probably just don't have enough fingers in the pie's of Angular/cli to know how it all hangs together, anyway.

We are now running everything at latest, 4.1.0 and CLI 1.0.1.

We updated all of our dependant packages of which thankfull we don't have many but some awesome people had already upgraded their projects to use Angular 4, some olders are still not updated but are working fine.

ng serve and prod build now all work fine, so I think we were stuck in a loop of cli version mismatching with angular version and also some 3rd party packages. I did go through and change custom filters we had created to ensure the right number of parameters were matching.

I know this could be a big step for some people but for us it was worth it and 2 of us sat down with a strong cup of tea and knocked it over in 2 hours.

Just got 1 package that a previous developer got from somewhere which has to be completely replaced.

Michael-D-Pine avatar Apr 27 '17 01:04 Michael-D-Pine

I'm sorry but this issue really is a duplicate of https://github.com/angular/angular-cli/issues/5623. The fix for the outstanding errors really is to fix your templates (e.g. change the variables that are private and need to be accessed in templates to public).

As mentioned in #5623 these really are AOT errors and it was a CLI bug that they weren't reported before.

We agree that it's a very bad experience to non-AOT builds to work, but then for AOT builds to not work. The plan for the future is to have AOT builds be fast enough they can be used even during development so this doesn't happen anymore, but we're not there yet.

filipesilva avatar May 03 '17 11:05 filipesilva

I think the main problem here is not that the build breaks but the fact that we get no info about where it breaks. My error was in some package I was using. Tracking that down is just a big PITA.

dhilgarth avatar May 03 '17 11:05 dhilgarth

#5601 gives better error reporting. We just need to be alittle patient for it to be released. Maybe a 1.0.2 ?

dherges avatar May 03 '17 11:05 dherges

Not sure if this was mentioned, but I found "private": true in package.json. After removing this line and restarting the app, ng build worked for me

MarvelMoe avatar May 15 '17 03:05 MarvelMoe