Cheat Sheet Membersihkan Cache
Zakiego
@zakiego
Daftar Isi
Latar Belakang
Saya sangat suka membersihkan cache. Rasanya memuaskan ketika mengosongkan penyimpanan dan memastikan development environment sebersih dan seefisien mungkin. Seiring berjalannya waktu, saya mengumpulkan command dan tools untuk memudahkan untuk mengelola dan menghapus cache untuk berbagai package manajer.
Catan
Harap diperhatikan, Anda harus memeriksa setiap perintah sebelum menjalankannya dan melanjutkannya dengan risiko Anda sendiri. Menghapus cache terkadang dapat menyebabkan masalah yang tidak terduga atau kebutuhan untuk mengunduh ulang packages dan rebuild projects.
Terlepas dari potensi kekurangan ini, menjaga cache tetap bersih membantu menjaga ruang kerja yang efisien dan terorganisir, memastikan bahwa file lama atau rusak tidak mengganggu development.
Cheat sheet
PNPM
pnpm store prune
Ref: https://github.com/orgs/pnpm/discussions/4413
NPM
npm cache clean --force
Ref: https://www.warp.dev/terminus/clear-npm-cache
Yarn
yarn cache clean
Ref: https://yarnpkg.com/cli/cache/clean
Bun
bun pm cache rm
Ref: https://bun.sh/docs/cli/pm
Node Modules
This tool allows you to list any node_modules directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space. Yay!
npkill
Ref: https://www.npmjs.com/package/npkill
Docker
Everything
docker system prune -a
# WARNING! This will remove:
# - all stopped containers
# - all networks not used by at least one container
# - all images without at least one container associated to them
# - all build cache
#
# Are you sure you want to continue? [y/N]
Container
docker container prune
# WARNING! This will remove all stopped containers.
# Are you sure you want to continue? [y/N]
Image
docker image prune -a
# WARNING! This will remove all dangling images.
# Are you sure you want to continue? [y/N]
The
-a
flag removes all unused images, not just the dangling ones.
Volume
docker volume prune
# WARNING! This will remove anonymous local volumes not used by at least one container.
# Are you sure you want to continue? [y/N]
Build Cache
docker buildx prune
# WARNING! This will remove all dangling build cache.
# Are you sure you want to continue? [y/N]
Network
docker network prune
# WARNING! This will remove all custom networks not used by at least one container.
# Are you sure you want to continue? [y/N]
Ref:
- https://depot.dev/blog/docker-clear-cache
- https://tech.forums.softwareag.com/t/how-to-clear-docker-cache/283214
NVM (Node Version Manager)
nvm cache clear
Ref: https://github.com/nvm-sh/nvm?tab=readme-ov-file
Next.js
Hapus .next
folder
Command ini dibuat menggunakan ChatGPT. Do with your own risk!
find . -type d -name ".next" -exec rm -rf {} +
Biome.js
Hapus folder ini:
- Linux:
~/.cache/biome
; - Windows:
C:\Users\<UserName>\AppData\Local\biomejs\biome\cache
- macOS:
/Users/<UserName>/Library/Caches/dev.biomejs.biome
Ref: https://biomejs.dev/guides/integrate-in-editor/#daemon-logs