Netlify deploy RangeError: Maximum call stack size exceeded

This morning I was deploying one of the site on our network to Netlify using the usual command:

netlify deploy --prod

But after the CDN diffing files I got the following error message

RangeError: Maximum call stack size exceeded

How To Fix

Firstly, create new file in /usr/bin/node_bin with the contents below:

#!/bin/bash

/usr/bin/node --stack-size=10000 $@

You can modify the stack-size number to higher number if needed.

After that, change the file permission to 755.

sudo chmod 755 /usr/bin/node_bin

Check netlify-cli installation path using which netlify command. Mine is located at /usr/bin/netlify since I installed netlify cli globally.

Edit the netlify file, change the first line from:

#!/usr/bin/env node

to

#!/usr/bin/env node_bin

This way the node will be invoked with custom --stack-size number.

I hope this is useful and happy deploying!