Ricardo
Ricardo

Reputation: 2487

angular 5 production build taking a lot of time and resources

I just upgrade my project from angular 4 to five. Testing the deployment process I face this issue: the compilation process never ends: I m running this command:

ng build --prod

my ng version is the following: Angular CLI: 1.6.4 Node: 8.2.1 OS: darwin x64 Angular: 5.2.0 ... animations, common, compiler, compiler-cli, core, forms ... http, platform-browser, platform-browser-dynamic ... platform-server, router

@angular/cli: 1.6.4
@angular-devkit/build-optimizer: 0.0.38
@angular-devkit/core: 0.0.25
@angular-devkit/schematics: 0.0.48
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.4
@schematics/angular: 0.1.13
@schematics/schematics: 0.0.13
typescript: 2.6.2
webpack: 3.10.0

the node process is taking a lot of memory. this is the output of my monitor

PID    COMMAND      %CPU  TIME     #TH   #WQ  #PORT MEM    PURG   CMPRS  PGRP  PPID  STATE    BOOSTS           %CPU_ME %CPU_OTHRS UID  FAULTS    COW    
9575  node         143.4 28:24.52 11/1  1    48    1691M+ 0B     0B     29574 29574 running  *0[1]            0.00000 0.00000    501  908303+   352
    29574  node         0.0   00:00.60 11    1    51    32M    0B     0B     29574 29518 sleeping *0[1]  0.00000 0.00000    501  15062     342

the ng build command just shows

11% building modules 11/23 modules 12 active ...orgchart/dist/css/jquery.orgchart.cssNode#moveTo was deprecated. Use Container#append.
 92% chunk asset optimization

any idea how to solve this issue? and finish my compilation process as usual ? thanks in advance

Upvotes: 4

Views: 2025

Answers (2)

kioi
kioi

Reputation: 339

Upgrade your @angular/cli to version 1.7.0 or greater, preferably 6.0.0 (which is at the time of this post on "beta")

That is @angular/cli: 1.6.4 to @angular/cli: ^1.7.0 or @angular/cli: ^6.0.0-beta.2

Upvotes: 0

alexKhymenko
alexKhymenko

Reputation: 5598

Have same issue on large project and in the end it usually crashes. Managed to fix it with adding more resources to the node.

"build": "node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --aot --prod",

npm run build

Upvotes: 6

Related Questions