corepack icon indicating copy to clipboard operation
corepack copied to clipboard

corepack cleanup cache

Open styfle opened this issue 2 years ago • 1 comments

If the local project is configured for the package manager you're using, Corepack will silently download and cache the latest compatible version.

Does corepack provide anyway to delete the cache?

The use case I'm thinking of is CI/CD where you want to set COREPACK_HOME to a cached directory. However, unlike node_modules, it doesn't seem like this directory is ever pruned or cleaned up since its shared between many projects.

On a local machine, its probably fine to just periodically delete it. But for CI/CD, the project is only ever using one version of a package manager so its safe to prune old or unused versions.

For perspective, pnpm versions released in the last 30 days (>=7.0.0) amount to 180 MB. I imagine this will reach GB very quickly.

I'm thinking this can be solved with a new command:

 # delete all except current version defined in package.json
corepack cache clean

# delete all versions that have not been invoked for 30 days
corepack cache clean --before 30d

styfle avatar May 31 '22 13:05 styfle

I find corepack is storing cache at ~/.node/corepack. Maybe you can delete them manually. image

summer-wu avatar Jul 07 '22 12:07 summer-wu

I find corepack is storing cache at ~/.node/corepack. Maybe you can delete them manually. image

~~I'll have a look at implementing this.~~ Is there an (implementation) variable or something that I can use to get the correct cache path for the current platform?

This one?

https://github.com/nodejs/corepack/blob/f539ae22e6c9f044576bc00f91cdd957de9ac8bc/sources/folderUtils.ts#L8

ST-DDT avatar Apr 17 '23 10:04 ST-DDT

Now corepack is eating 190 MiB of my disk space. Cache cleaning is becoming more and more important.

image

SukkaW avatar Nov 13 '23 04:11 SukkaW

Its been about a year and I checked again just now:

$ du -sh ~/.cache/node/corepack

1.6G

styfle avatar Dec 29 '23 17:12 styfle

Now corepack is eating 190 MiB of my disk space. Cache cleaning is becoming more and more important.

It is becoming worse:

image

70 days passed and the folder size increased by 130 MiB.

SukkaW avatar Jan 25 '24 07:01 SukkaW