Grunt throws a Maximum call stack size exceeded error

Grunt throws a ‘maximum call stack size exceeded’ error after running a simple task, and you haven’t got the slightest idea what it means. No sweat.

But I can’t blame as this is just what happened to me today while working on a website redesign. The grunt task is a simple ‘imagemin’ task I decided to run separately, and I don’t recall having had the same issue before.

Cut a long story short, you launch something along the lines of: “grunt imagemin” in your terminal, and you’re thrown the following error:

RangeError: Maximum call stack size exceeded

Don’t name your task aliases like your tasks

I did not find the issue in Grunt’s documentation but managed to find it in my search results.

You can not name your tasks like the task itself, as detailed here.

So I went from:

grunt.registerTask("imagemin", ["imagemin"]);

to

grunt.registerTask("imageminifier", ["imagemin"]);

… and it worked like a charm.