打包异常:超内存
Nodejs 分配的默认内存可能比较少,流水线打包时,容易超出内存限制
如:
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
方案一:命令前加一行,通过环境变量改变分配内存大小
export NODE_OPTIONS=--max_old_space_size=4096方案二:package.json 中改命令
{
"scripts": {
"build": "node --max_old_space_size=4096 node_modules/vite/bin/vite.js build
}
}