yarn fills up disk - workaround

Yarn 1.x has a known issue where it fills up the disk over time, as it caches downloaded packages and never deletes them.

workaround - use yarn cache clean

example from package.json:

  "devDependencies": {
    "basic-parser": "file:../parsers/basic-parser",
   }

where ../parsers/basic-parser points to another folder that contains another package.json

Then regularly (after each yarn) run yarn cache clean for each local package:

yarn cache clean "basic-parser"

This seems to free up the disk space.


Also you can execute this cleanup step automatically, as part of the postinstall step of the consuming package:


in the consuming package.json:

  "scripts": {
    "postinstall": "yarn cache clean basic-parser && yarn cache clean my-other-package"
  }, 

cleaner than a bash script :) 


To read more, see the issue.


Comments