Webpack Uglify plugin returns “Killed” on Ubuntu

感情迁移 提交于 2019-12-02 23:03:38

As @barbuza suggested, it was a memory issue. I too am using a Digital Ocean VPS that only has 512 MB of RAM (yes, I'm cheap). That's not enough for webpack's uglify plugin. Adding 2GB of swap space on the server solved the issue. I followed this article to set that up: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

Purkhalo Alex

Same thing happened with me while Digital Ocean VPS using, as mentioned above - that happens because of building takes to much RAM for your machine, so it's "out of memory usage".

To solve this you can minimize RAM usage while file compiling via ---max_old_space_size option, here is an advanced example of usage

node --max_old_space_size=1096 node_modules/webpack/.bin/webpack.js

Of course you can choose any size, also you can do the same with webpack-dev-server. And you don't need to add the swap space until it will be really needed for other purposes, such as you run this command only once to compile the bundle.js file.

I had the same issue on digital ocean vm, it turned out there was no swap configured, so it just run out of memory.

You can also run ng build on your local machine and then copy the dist folder to your remote like this:

scp -r path/to/local/folder user@x.x.x.x:/path/to/remote/folder
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!