I believe in the world of NPM, you encounter problems that are hard to solve. Has it ever made your head spin trying to execute npm run build on your server or your local environment? For example, like getting the below error message.

Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! project-nuxt@1.0.0 build: `nuxt build`
npm ERR! Exit status 137
npm ERR! 
npm ERR! Failed at the project-nuxt@1.0.0 build 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!     /home/administrator/.npm/_logs/2021-04-11T08_48_48_675Z-debug.log

If yes, you are not alone. The error message “Exit status 137” refers to a situation when NPM doesn’t have enough memory to compile your code in your potato server. What npm run build does is run the script “build” in package.json which normally is a script to compile or build or run your application. So basically, it’s a RAM eater, family 😅.

In this article, I’m going to share the solution based on my experience.

What is the solution?

There is a way to overcome this issue which is to limit the maximum memory you want to use to build your package.json.

Go to package.json and see the script

....
"scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
},
....

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

#coding #nodejs #javascript #programming

How to Run ‘npm Run Build’ on A Low Spec Server?
7.20 GEEK