Run grunt task with node.js arguments on Windows

[亡魂溺海] 提交于 2019-12-10 18:23:39

问题


I am running into an out of memory error when running grunt babel. It is solved on mac by increasing max-old-space-size. However some of our developers are on windows machines and I have not found a way to do this on windows.

What is the equilevant of:

node --max-old-space-size=10000 node_modules/.bin/grunt babel

on windows?

Or is there a universal command that works on both?

My dependencies:

"@babel/core": "^7.1.5",
"@babel/preset-env": "^7.1.5",
"grunt-babel": "^8.0.0",
"grunt": "^0.4.5",
"grunt-cli": "^1.3.1",
My babel config in gruntfile.js

My babel config in gruntfile.

babel: {
  options: {
    compact: true,
    presets: ['@babel/preset-env'],
    sourceMap: true,
    inputSourceMap: sourceMapInJson)
  },
},

Error I was getting on Mac and still getting on Windows without increasing max-old-space-size:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Error I am getting on Windows with max-old-space-size param:

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
         ^^^^^^^

SyntaxError: missing ) after argument list

回答1:


Npm package increase-memory-limit would help.

this module fix heap out of memory when running node binaries.

As mentioned in its official docs

it will append --max-old-space-size=4096 in all node calls inside your node_modules/.bin/* files.

Hope this helps!



来源:https://stackoverflow.com/questions/53299430/run-grunt-task-with-node-js-arguments-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!