vue项目内存溢出

  1. removeCache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require("fs");
const child_process = require("child_process");

/*
*@functionName: deleteFolder
*@params1: 删除的文件路径
*@description: 删除项目中的缓存文件
*/
const deleteFolder = async function (path) {
var files = [];
if (fs.existsSync(path)) {
files = fs.readdirSync(path);
files.forEach(function (file, index) {
var curPath = path + "/" + file;
if (fs.statSync(curPath).isDirectory()) {
// recurse
deleteFolder(curPath);
} else {
// delete file
fs.unlinkSync(curPath);
}
});
await fs.rmdirSync(path);
}
};
deleteFolder("./node_modules/.cache/compression-webpack-plugin");
  1. package.json
1
2
3
4
5
{
"script": {
"rmcatch": "node ./removeCache.js"
}
}