在Windows上使用node.js参数运行grunt任务 [英] Run grunt task with node.js arguments on Windows

查看:400
本文介绍了在Windows上使用node.js参数运行grunt任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行grunt babel时遇到内存不足错误。它通过增加max-old-space-size在mac上解决。然而,我们的一些开发人员在Windows机器上,我还没有找到在Windows上执行此操作的方法。

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.

什么是以下的等价物:

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

在Windows上?

或者是否存在适用于这两种情况的通用命令?

Or is there a universal command that works on both?

我的依赖项:

"@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

我的babel配置在gruntfile中。

My babel config in gruntfile.

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

错误我上了Mac并且仍然在不增加最大旧空间的情况下上Windows大小:

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

错误我在Windows上使用max-old-space-size param:

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


推荐答案

Npm包 increase-memory-limit 会有所帮助。

Npm package increase-memory-limit would help.

此模块在运行节点二进制文件时修复堆内存不足。

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

如上所述在其官方 docs


它会在你的node_modules / .bin / *文件中的所有节点调用中附加--max-old-space-size = 4096。

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

希望这会有所帮助!

这篇关于在Windows上使用node.js参数运行grunt任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆