Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Not able to run angular-cli command to build production

I have an Angular app, when I build this app in development environment (npm run build) it works completely fine.

But when I try to build with production tag, it fails with this error:

C:/Users/1234/app/src/$$_gendir/app/app.component.ngfactory.ts (617,85): Property 'router' is private and only accessible within class 'AppComponent'.

I know router is private (in below code), but how is it working fine for development instance, and none but AppComponent.html should be able to use that?

@Component({
    selector: 'my-app',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})

export class AppComponent {
    constructor(private router: Router, private _cookieService:CookieService) {
        //some function
    }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Production build is stricter and thus doesn't let you access private objects outside of scope. You app.component.html will not be able to access router directly. You could write a public function in your app component and call the private router from within.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!