Change - max stack size for grunt job

In my GruntJS script, I encountered the following error:

Maximum Call Stack Size

What is the correct syntax for calling the node flag --max-stack-size= in my grunt command so that I can allocate a large amount of memory for the stack?

+4
source share
4 answers

If you are not doing very high level programming in GruntJS, I think you can register a cyclic task.

If you name the task the same name as the plugin, it will work endlessly:

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

This leads to the challenge of the task itself.

To check what you are doing, run grunt with the --verbose (or --v) command to find out what grunt is.

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

If, however, you are sure that you are running run grunt with --max-stack-size=10000 or something else ...

+5
source

Install grunt-cli locally with npm install grunt-cli , then invoke it locally with

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

You are probably getting this error due to infinite recursion that needs to be fixed.

+1
source

This should work on linux or mac:

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

10000 can be replaced with any size you need.

The default is 984 on my mac and on the ubuntu server I was working on recently.

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

 alias grunt='node --stack-size=10000 `which grunt`' 
+1
source

A similar problem occurs with me when I dynamically name tasks through grunt.task.run() . Grunt success callbacks seem to populate the NodeJs stack.

I did the manual editing c:\Users\%UserName%\AppData\Roaming\npm\grunt.cmd (on Windows). Add the parameter supported by your version of node, for example --stack_size=2000 (for more details see node -help ).

0
source

Source: https://habr.com/ru/post/1487962/


All Articles