Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set "--max-old-space-size" when using gradle-node-plugin or force in in node config?

I am using https://github.com/srs/gradle-node-plugin to launch NPM tasks as part of my build.

But, webpack is now running out of heap space, reporting FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I can't figure out any way to tell the the NpmTask to pass the --max-old-space-size flag directly to node (placing it anywhere in the NpmTask args property ends up passing the flag as an argument to the npm script, which ignores it or to webpack which fails because it doesn't know the arg).

I found this github issue: https://github.com/srs/gradle-node-plugin/issues/141, but it only seems to relate to the NodeTask, not NpmTask. Looking at it, I'm thinking NpmTask needs to be extended with an extra options property like NodeTask now has.

Is there a global config "node.js" way I can force node to use more heap space until I figure out how to get NpmTask to do what I want?

like image 259
Shorn Avatar asked Apr 04 '17 06:04

Shorn


1 Answers

Provide the NODE_OPTIONS environment variable when running Gradle:

NODE_OPTIONS="--max-old-space-size=1024" ./gradlew myNpmTask
like image 104
Vic Seedoubleyew Avatar answered Nov 15 '22 06:11

Vic Seedoubleyew