How to execute nuxt NPM run build on low spec server?

Have you ever encounter below error message after you trying to execute “npm run build” in your server?

The error message “Exit status 137” is mostly referring to NPM doesn’t have enough memory to compile your code in your potato server.

Such a RAM eater 😅

There is a way to solve this issue.

Limit the maximum memory

Go to package.json and see the script

All we need to specify the limitation memory at the build stage. To avoid error 137, increase memory limit amount by using argument —-max-old-space-size. It will help avoid a memory limit issue. For example,

Choose your desire value and replace it

Save and NPM run build again 🍻

IF above doesn’t work, please check if there is swap memory available. IF NOT, Create swap file by following below step

Check the system swap information by running this command

If you don’t get back any output, this means your system does not have swap space available currently. If you already have, there is might be some other problem.

Before creating swap, should check the current disk usage

So based on example, there is plenty of space available. Proceed to create swap file

By this point, your swap file is created. Try rerun the “npm run build”

~~~ Happy Working ~~~

Software Engineer at

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store