javascript - 在 Windows 上使用 node.js 参数运行 grunt 任务
问题描述
运行 grunt babel 时遇到内存不足错误。在 mac 上通过增加 max-old-space-size 来解决。然而,我们的一些开发人员在 Windows 机器上,我还没有找到在 Windows 上执行此操作的方法。
什么是等价物:
node --max-old-space-size=10000 node_modules/.bin/grunt babel
在窗户上?
或者是否有一个通用命令适用于两者?
我的依赖:
"@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
我在 gruntfile 中的 babel 配置。
babel: {
options: {
compact: true,
presets: ['@babel/preset-env'],
sourceMap: true,
inputSourceMap: sourceMapInJson)
},
},
错误我在 Mac 上仍然在 Windows 上而不增加 max-old-space-size:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
我在带有 max-old-space-size 参数的 Windows 上遇到错误:
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
解决方案
Npm 包increase-memory-limit
会有所帮助。
此模块在运行节点二进制文件时修复堆内存不足。
如其官方文档中所述
它将在您的 node_modules/.bin/* 文件中的所有节点调用中附加 --max-old-space-size=4096 。
希望这可以帮助!
推荐阅读
- javascript - 如何获取元素索引
- sql - 如何使用字典更新 SQL 中的多行?
- python - Python pytesseract 从图像中提取不正确的数据
- jq - 整个对象树的正则表达式替换/对“tostring”的反向操作
- angular - 一次更新所有过时的 Angular 包
- javascript - 如何通过 ReactJS 向我的 html 元素添加类属性?
- react-native - React-natve :下划线文本之间的空格
- javascript - 如何将正确的响应数据插入 Jest?
- android - LinearLayout 水平方向不适用于 RecycleView 元素
- scala - 用于序列生成器的 Spark UDF