There is an example of cleaning old repos for a different repository provider here. The idea is that it searches through all the index files for a dependency - looks at the last index time for the index file and then if that access time is greater than a specific duration (5 mins or 150 days depending on what you specify) then it deletes the parent directory. It looks like this:
find ~/.m2 -amin +5 -iname '*.pom' | while read pom; do parent=`dirname "$pom"`; rm -Rf "$parent"; done
I'd like to do this same thing for npm. My question is - How to clean old dependencies from npm repositories?
Note. I'm not interesed in npm prune
. It doesn't do time-based cleaning (the scenario is that I have multiple JS builds running concurrently and am interested in optimising disk space usage).