Andrew Carreiro
Andrew Carreiro

Reputation: 1567

Changing --max-stack-size for grunt task

I'm running into the following error in my GruntJS script:

Maximum call stack size exceeded"

What's the proper syntax for invoking the node flag --max-stack-size= in my grunt command so I can set aside a larger amount of memory for the stack?

Upvotes: 4

Views: 7584

Answers (4)

Henry
Henry

Reputation: 7881

This should work on linux or mac:

node --stack-size=10000 `which grunt`

The 10000 can be replaced by whatever size you require.

The default is 984 on my mac and on an ubuntu server I've been working on lately.

Another option is to add this to your .bashrc, .bach_profile or equivalent:

alias grunt='node --stack-size=10000 `which grunt`'

Upvotes: 1

p.stovik
p.stovik

Reputation: 1

Similar issue happend to me when I dynamicaly called tasks via grunt.task.run(). Seems that grunt's success callbacks filled tha NodeJs stack.

I performed manual edit of c:\Users\%UserName%\AppData\Roaming\npm\grunt.cmd (on Windows). Add parameter supported by your version of node, e.g --stack_size=2000 (for details use node -help).

Upvotes: 0

Gilad Peleg
Gilad Peleg

Reputation: 2010

Unless you are doing some very high-level programming in GruntJS I think you may have a cyclic task registered.

If you name a task the same name as plugin it will run an infinite amount of times:

grunt.registerTask('uglify', ['uglify'])

This results in the task calling itself.

In order to verify what you're doing, run the grunt with --verbose (or --v) command to see what grunt is running.

For instance run grunt uglify --v and notice how many times it runs. This can be fixed easily by changing the task name to something else.

If however you're sure of what you're doing run grunt with --max-stack-size=10000 or whatever...

Upvotes: 6

Kyle Robinson Young
Kyle Robinson Young

Reputation: 13762

Install grunt-cli locally with npm install grunt-cli then call it locally with:

node --max-stack-size=val ./node_modules/.bin/grunt

Although likely you're getting that error because of an infinite recursion that should be fixed.

Upvotes: 2

Related Questions