Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass options to node when using babel-node

Babel CLI docs (https://babeljs.io/docs/usage/cli/):

babel-node [options] [ -e script | script.js ] [arguments]

But when trying to increase allocated memory for Node:

babel-node --max-old-space-size=16384 script.js

argument --max-old-space-size=16384 seems to be ignored

Does sb know if this should work, and if shouldn't - some workaround?

like image 545
Pavel 'Strajk' Dolecek Avatar asked Jul 10 '16 17:07

Pavel 'Strajk' Dolecek


2 Answers

Edit: (Juli 2016) As of version 6.11.4 all variations are supported now. The example posted in the question works now.


Babel in version 6.11.3 does not support all variations of v8Flags yet.

Node itself supports passing this flags either with underscore (--max_old_space_size) or dashes (--max-old-space-size).

In contrast babel-node only supports these flags if the are specified with underscores and does not support the format --flag=value.

There is a open pull request, that addresses this issues. Sadly there is no current workaround for specifying v8Flags with values.

like image 166
Daniel T. Avatar answered Oct 22 '22 05:10

Daniel T.


I am using Babel 7, and this does in fact work.

babel-node --max-old-space-size=16384 script.js

Easy way to test is to just lower the size to 100KB, and you will run out of memory quickly.

like image 38
Chad Scira Avatar answered Oct 22 '22 07:10

Chad Scira