Try ERPNext Buy Support Partners Foundation

Frappe App Build Failed - Javascript Heap out of Memory

Hi All,
I tried Fresh Setup by installing a Frappe using the easy install. The Installation say successful. But the css and js files were missing. When we dig deeper, we found that the build of frappe app failed with the following message “ineffective mark-compacts near heap limit allocation failed - javascript heap out of memory frappe”

Same Issue was already reported by @sonyvec. However the solution was not working.

Could some one help us in why this error is happening? how to solve this.


I solved this by increasing max-old-size to 2048 and expanding my swap partition to 2gb (which should sum up to 2.5gb total ram on my raspberry, where .5gb are actual ram and 2 are swap).
If you can modify your swap on the go, remember to reboot your server

Wow! ERPNext on a raspberry?

I increased the swap size to 4GB. Still the same error.

I solved the issue. Might be helpful for other having the same. Downgrading Node version solves the issue.

Step 1: npm install -g n

Step 2: n e.g n 8.17.0

Exit the terminal

Step 3: node -v
The downgraded version 8.17.0 should appear

Step 4:go to the frappe bench/apps/frappe

step 5: yarn install

step 6: sudo bench build --app frappe

Now Frappe is build successfully.

What I’ve also done, to be able to keep the same version of Node is the following:

Go to: /home/frappe/frappe-bench/apps/frappe/node_utils.js

On lines:

“build”: “node rollup/build.js”,
“production”: “FRAPPE_ENV=production node rollup/build.js”,
“watch”: “node rollup/watch.js”

Change them to:

“build”: “node –max-old-space-size=8192 rollup/build.js”,
“production”: “FRAPPE_ENV=production node –max-old-space-size=8192 rollup/build.js”,
“watch”: “node –max-old-space-size=8192 rollup/watch.js”

This has solved the issue for me.

I’ve been trying to tackle this issue for quite some time. Usually adding some swap space helps, but it doesn’t guarantee anything. My PR to update Node’s memory usage dynamically by checking the availability before running rollup didn’t go anywhere.

So I’ve written a new feature which builds and maintains assets. This only works on develop and the next v13-beta. However, this feature enables assets to be packaged and attached to the GitHub releases that will be made henceforth. If you can craft an alternative script to utilize those assets instead of having to build on your servers.

Also, if you’re comfortable with docker, Frappe Docker could also work for you.