我的tsc
工作在FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
的gitlab上失败了
我正在运行的脚本是tsc -p test/tsconfig.json --noEmit
到目前为止,我尝试的是通过以下方式增加max-old-space-size
:
cross-env NODE_OPTIONS=--max-old-space-size=8192 yarn print:heapsize && tsc -p test/tsconfig.json --noEmit
cross-env NODE_OPTIONS='--max-old-space-size=8192' yarn print:heapsize && tsc -p test/tsconfig.json --noEmit
(只是var)node --max-old-space-size=8192 ./node_modules/.bin/tsc -p test/tsconfig.json --noEmit
周围的额外引号)
选项#1和#2不工作,#3工作正常,但运行二进制文件并将param传递给node cli
听起来不太好。
因此,我的问题是-我如何通过max-old-spce-size
env variables
为 tsc
设置,或者有其他好的方法?
yarn print:heapsize
是我用来检查当前大小的脚本--它为#1和#2显示了8gb,如下所示:
"print:heapsize": "node -e \"console.log(' Current heap size:', (require('v8').getHeapStatistics().total_available_size / 1024 / 1024 / 1024).toFixed(2), 'Gb')\""
这是输出
发布于 2021-10-01 17:02:54
前两个选项失败,因为环境变量NODE_OPTIONS=--max-old-space-size=8192
只应用于&&
之前的第一个命令(yarn print:heapsize
)。
如果删除yarn print:heapsize &&
,环境将像预期的那样应用于编译命令:
cross-env NODE_OPTIONS=--max-old-space-size=8192 tsc -p test/tsconfig.json --noEmit
发布于 2022-05-20 15:53:14
不建议使用tsc
,但可以在NODE_OPTIONS
中使用ts-node
和--max-old-space-size
将此选项添加到package.json
中
{
"scripts": {
"start": "NODE_OPTIONS='--max-old-space-size=8192' ts-node index.ts"
}
}
https://stackoverflow.com/questions/69408024
复制相似问题