Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal amandeepmittal/blog.md Secret
Created Aug 10, 2017

Embed
What would you like to do?

node_modules tend to take a lot of space in your local system especially if you work with Node.js or related frameworks (such as client side frameworks: React or Angular). They are the part and parcel of modern day JavaScript applications and workflow.

Each day npm registry is getting around 350 million downloads daily, at the current time of writing this post. That's almost 2.2 billion downloads per week and you can take the calculation further.

Here's Laurie Voss (@seldo) tweet, sharing the aforementioned details:

Nonetheless, after all your efforts are paid of and everything is deployed and is over cloud, either Github or some deployment service you or your client prefers, I think it will be generous to remove node_modules that take useful space on our local machines (especially, Mac users with limited GigaBytes of SSD).

There's a simple command that you can run in your terminal either in a folder or from the root.

https://gist.github.com/7eb7316c8677641dcd9eca8f53590fb8

This will delete node_modules folder in every local repository/directory that's on your system so take precaution or exclude those projects that you are currently working on.

However, don't panic. Everything can be back to normal just by going into the project's directory and running package installing command:

https://gist.github.com/8746bbd3fb648a5e09b89af592e2642c

I have used this command earlier today it saved me up to 9 GB of space from local system over several projects.

I even replaced node_modules with bower_components to do the same thing:

https://gist.github.com/336f8b47491c4d36cb2af86418cd4ff5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.