Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 CLI too slow after ng serve and when updating

I have pasted a screenshot after i run ng serve. it is on 34946 ms. it is pretty slow and it is hurting the performance of our team. When we also update our code, it takes too long to reload the page.

enter image description here

My version of angular is Angular CLI version (1.2.7)

Is this an issue or is this normal in Angular CLI?

We already have around 40 components on the project but i am not sure if it affects the loading performance.

Here is the specs of my PC just incase.

enter image description here

like image 441
Voltaire John Secondes Biton Avatar asked Aug 22 '17 13:08

Voltaire John Secondes Biton


3 Answers

You Just Need to update angular cli version I hope this will solve your issue

 npm install @angular/cli@latest     

If this one Does not solve your Issue Means Just Run using this Cmd

 ng serve --sourceMap=false    
like image 120
Mohamed Imran Avatar answered Nov 07 '22 23:11

Mohamed Imran


i solved my problem. What happened is that our components and other resources are all imported in app.module.ts. Because of this, the page loads all the resources every time the page loads. My solution was to apply Lazy Loading to load only those resources that are specific to the routes that i am accessing and it did fix up the loading issue.

like image 32
Voltaire John Secondes Biton Avatar answered Nov 07 '22 22:11

Voltaire John Secondes Biton


You have this problem is because your dev PC have not enough memory to handle the build as nodejs is consuming a lot of memory when you run expensive npm tasks. And the bigger your project the more memory is required to complete the task. The problem can get even worse if you want to run ng serve + ng t + ng whatewer at the same time.

Check the Task manager -> Perfomrmance tab then run ng serve and you will see what I am talking about.

I had struggled by the same problem until I put another 8gb RAM in my dev PC.

So yes it is normal.

like image 23
angularrocks.com Avatar answered Nov 07 '22 23:11

angularrocks.com