Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NG serve takes long time to start

Tags:

angular

I'm working on Angular 9.1.4 node 14.0.

Now I'm facing a trouble which is whenever trying to run

ng serve

its taking long time to start. I'm trying to compile a theme I have got from themeforest. no installation issue at all with npm install which all works fine and I also updated all the packages in packages.json as well.

Still the serve command is very slow

like image 916
Sandeep Thomas Avatar asked May 02 '20 02:05

Sandeep Thomas


People also ask

Why is NG serve Taking time?

This is mostly because of bulky source map files. When you do ng serve , Angular serves the app from memory instead of the dist folder (the file system). This means the entire code (along with map files) will be loaded into the system's memory and this is the main reason why your system or IDE getting slow.

How long does it take to Ng serve?

11), ng serve takes about 1 minute to serve the app, but the ng-serve --source-map=false takes somewhere from 10 to 30 seconds.

What happens when Ng serve runs?

ng serve is a great command to use when developing your application locally. It starts up a local development server, which will serve your application while you are developing it. It is not meant to be used for a production environment.


3 Answers

Most of the time ng serve takes too long because of @angular-devkit downgrading the version might work. Since you are using angular 9 you can enable ivy compilation in tsconfig file by adding "angularCompilerOptions": { "enableIvy": true }

like image 75
Lasanga Guruge Avatar answered Oct 18 '22 02:10

Lasanga Guruge


You can specify the --source-map=false attribute for Angular to load only the stuff that it needs, and will recompile only those parts of your application, that have been modified.

ng serve --source-map=false

In my case (Angular v.11), ng serve takes about 1 minute to serve the app, but the ng-serve --source-map=false takes somewhere from 10 to 30 seconds. Moreover, changes are applied much more faster.

like image 36
Dorin Baba Avatar answered Oct 18 '22 03:10

Dorin Baba


Use the --verbose option to see what's going wrong behind the scenes:

ng serve --verbose
like image 1
Shadi Namrouti Avatar answered Oct 18 '22 02:10

Shadi Namrouti