If you don’t want to erase the whole .julia folder, but still need to clean things up every now and then, use GitHub - giordano/PkgCleanup.jl: Cleanup unused Julia environments and artifacts
I wish Julia itself had a ] cleanup command, and that juliaup erased all artifacts that were built in versions that are no longer installed.
Related: How to cleanup artifacts folder