我有一个Nx monorepo (https://nx.dev)。它有一个带有Nx缓存的文件夹(./node_modules/.cache/nx/)。目前它的大小超过3 3GB。
是否有清除此缓存的命令?
发布于 2021-04-01 01:31:28
只需删除整个'nx‘缓存文件夹:
rm -rf ./node_modules/.cache/nx发布于 2021-01-27 17:19:51
我已经实现了这样一个解决方案,但我觉得它并不方便。也许NX有一个清除缓存的命令,但我没有找到它。
package.json
"scripts": {
"nx": "nx",
"postnx": "node checkAndClearCache.js",
...checkAndClearCache.js
const fs = require('fs');
const rimraf = require('rimraf');
const getSize = require('get-folder-size');
const cachePath = 'node_modules/.cache/nx';
const maxCacheMb = 2048;
if (fs.existsSync(cachePath)) {
getSize(cachePath, (err, size) => {
if (err) {
throw err;
}
const MBSize = (size / 1024 / 1024).toFixed(2);
console.log(`*** NX cache size is ${MBSize} Megabytes`);
if (MBSize > maxCacheMb) {
console.log('*** CLEAR NX CACHE ***');
rimraf.sync(cachePath);
}
});
}发布于 2022-02-12 15:16:37
这在今天(2022年2月12日)的最新版本中有效。我不确定为什么它不再出现在CLI文档中,尽管有证据表明它过去就存在:https://nx.dev/cli/clear-cache
nx clear-cache
https://stackoverflow.com/questions/65916135
复制相似问题