There are so many projects that I start working throughout the year. Some are to show some functionality, a talk, or a demo. Today I was archiving them and cleaning up.
I don't want to lose the code when cleaning up, but I also don't want to zip them. I need to have my projects in a place without using much space. I move them to an Archive
folder and delete vendor
and node_modules
folders.
These are the steps of what I do.
1. Create an Archive
folder:
mkdir Archive
mv my-old-project/ Archive/
2. Find out how much space each node_module or vendor folder is using.
The Commands find
and du
are your friends. Use man find
to find out how to use it and available parameters.
find . -name "node_modules" -type d -prune | xargs du -chs
You will get a result similar to the following:
35M ./Archive/platzifood/node_modules
201M ./Archive/superapp/node_modules
202M ./Archive/rapiddev-meetup/node_modules
3. Deleting, removing these folder is as easy as executing the following:
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
As you can see, it is the same command adding the -exec rm -rf '{}' +
for removing every result.
Summary
This way, I save tons of space, and in case I want to go back and rerun them, I execute a simple npm install
or composer install,
and I have them back.