Report this

What is the reason for this report?

MEAN stack - Angular SSR build killed

Posted on November 6, 2019

I am having issue with deploying my MEAN stack application to droplet.

Here is my droplet information -

Ubuntu 18.04.3 (LTS) x64 1 vCPUs 1GB / 25GB Disk

I am following a tutorial to set up the application in droplet -

https://jasonwatmore.com/post/2018/09/26/setup-nodejs-mongodb-production-server-on-ubuntu-1804

My application is working fine in localhost. But when try to build server side rendering with following command npm run start, having following error -

> product-bot@0.0.0 start /opt/product-bot
> npm run build:ssr && npm run serve:ssr


> product-bot@0.0.0 build:ssr /opt/product-bot
> npm run build:client-and-server-bundles && npm run webpack:server


> product-bot@0.0.0 build:client-and-server-bundles /opt/product-bot
> ng build --prod && ng run product-bot:server

 19% building modules 79/128 modules 49 active …modules/@angular/cdk/esm5/layout.es5.jsKilled
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! product-bot@0.0.0 build:client-and-server-bundles: `ng build --prod && ng run product-bot:server`
npm ERR! Exit status 137
npm ERR! 
npm ERR! Failed at the product-bot@0.0.0 build:client-and-server-bundles script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-11-06T11_52_18_839Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! product-bot@0.0.0 build:ssr: `npm run build:client-and-server-bundles && npm run webpack:server`
npm ERR! Exit status 137
npm ERR! 
npm ERR! Failed at the product-bot@0.0.0 build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-11-06T11_52_18_902Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! product-bot@0.0.0 start: `npm run build:ssr && npm run serve:ssr`
npm ERR! Exit status 137
npm ERR! 
npm ERR! Failed at the product-bot@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-11-06T11_52_18_923Z-debug.log

If it is something related to my code, it couldn’t work in localhost. Or I am missing something in configuration.

Thanks in advance!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

The error message “Killed” with the error code “137” is usually a sign that your process was killed by the system due to a lack of resources, most commonly not enough RAM. In your case, your droplet has only 1GB of RAM and that might not be sufficient for your Angular build process.

Angular builds, especially in production mode and with server-side rendering enabled, can be quite resource-intensive. This is even more true if your application is large or complex.

There are a few ways you could potentially resolve this:

  1. Upgrade your Droplet: The simplest solution would be to upgrade your droplet to a larger one with more RAM. This would give your build process more memory to work with.

  2. Create a Swap file: If upgrading your droplet isn’t an option, you could create a swap file. A swap file allows your system to use disk space as extra memory when it runs out of RAM. However, this is much slower than using RAM, and if your system is constantly swapping, it can significantly degrade performance. But it could be a good stopgap measure to get your build to complete. Here’s a guide on how to create a swap file on Ubuntu 18.04.

  3. Optimize your build process: If your application is very large, you might be able to reduce memory usage by optimizing your build process. This could involve things like code splitting or lazy loading modules, which can reduce the size of your initial build. However, this can be complex and may not be feasible depending on your application.

Remember, if you choose to create a swap file, this should only be a temporary measure. If your system is regularly using swap, it’s a sign that you need more RAM. Over-reliance on swap can lead to poor system performance and decreased lifespan of your storage drive.

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.