Urukhay
Urukhay

Reputation: 421

Why does Angular-CLI 'ng build' shows "Killed"?

When I added a new module, ng build process just getting killed.

enter image description here

Upvotes: 26

Views: 29208

Answers (5)

Kurt Van den Branden
Kurt Van den Branden

Reputation: 12943

This is a memory problem. If you can't add extra physical memory, you could create a swap file to add extra RAM memory.

// Create a swapfile
sudo fallocate -l 4G /swapfile

// Set up the swapspace
sudo mkswap /swapfile

// enable swapfile
sudo swapon /swapfile

The swapfile won't be recreated if you reboot. In case you want your swapfile to be permanent, edit the stab file with sudo nano fstab and add the following line to it:

/swapfile   none    swap    sw    0   0

Upvotes: 31

Stefanos Kargas
Stefanos Kargas

Reputation: 11073

For Centos 7

An addition to Kurt's answer. Creating a swap file in Centos 7 won't work with the suggested commands. The fallocate command does not work well in Centos 7 and creates the following error when calling swapon:

swapon: /swapfile: swapon failed: Invalid argument

Also you are advised to change permissions of file to 0600 before enabling swap file. So, eventually you can do the following:

sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
sudo mkswap /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile

Upvotes: 1

WapShivam
WapShivam

Reputation: 964

I also face this problem on Linux Server. This is memory issue. Linux server is not enough for webpack's uglify plugin, So Adding extra memory space on the server solved the issue

Upvotes: 1

zardilior
zardilior

Reputation: 2978

Linux will kill processes when it's low on memory which means your process is eating more memory than there is available. To regulate Node's memory usage you can use:

node --max_old_space_size=1096 ./node_modules/@angular/cli/bin/ng build --prod

where 1096 can be replaced by the memory you have left

Another solution is to add memory, or free it. This can be done by adding swap for example

Upvotes: 4

angularconsulting.au
angularconsulting.au

Reputation: 28289

as from this comment here:

I think this is a memory issue. Linux will kill processes when it's low on memory. See http://stackoverflow.com/questions/30747314/webpack-uglify-plugin-returns-killed-on-ubuntu

Upvotes: 40

Related Questions