corepack
corepack copied to clipboard
corepack cleanup cache
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
I find corepack is storing cache at ~/.node/corepack
. Maybe you can delete them manually.
I find corepack is storing cache at
~/.node/corepack
. Maybe you can delete them manually.
~~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
Now corepack
is eating 190 MiB of my disk space. Cache cleaning is becoming more and more important.
Its been about a year and I checked again just now:
$ du -sh ~/.cache/node/corepack
1.6G
Now
corepack
is eating 190 MiB of my disk space. Cache cleaning is becoming more and more important.
It is becoming worse:
70 days passed and the folder size increased by 130 MiB.