Improve npm cache cleanup fallback logic

Adds a fallback to manually remove the npm cache directory if 'npm cache clean --force' fails during cleanup. This ensures the cache is cleared even if the npm command encounters an error.
This commit is contained in:
CanbiZ
2025-12-18 12:09:52 +01:00
parent 7d865172ae
commit f0f0a63f6c

View File

@ -818,7 +818,10 @@ cleanup_lxc() {
# Node.js npm
if command -v npm &>/dev/null; then
$STD npm cache verify 2>/dev/null || true
$STD npm cache clean --force 2>/dev/null || true
# Clean cache with fallback to manual removal if command fails
if ! $STD npm cache clean --force 2>/dev/null; then
rm -rf /root/.npm/_cacache 2>/dev/null || true
fi
fi
# Node.js yarn
if command -v yarn &>/dev/null; then $STD yarn cache clean || true; fi