So it turns out that instead of needing to alias npm or otherwise call node directly, you can increase Node's max heap size by setting the NODE_OPTIONS environmental variable (introduced in Node 8) as follows:
NODE_OPTIONS=--max_old_space_size=8192
Usage with NPM scripts:
"scripts": {
"start": "cross-env NODE_OPTIONS=--max_old_space_size=8192 webpack"
}
或者,每次都在执行npm命令前执行一次
export NODE_OPTIONS=--max-old-space-size=8192