Node_Modules is huge! Is this normal?

So I’ve recently tried getting into the Angular JS framework, which requires that I use npm scripts to compile my code into JavaScript. The problem is that just installing npm modules in a single project takes up like 47MB. I know that I’m supposed to add the node_modules folder to the .gitignore file so that I don’t actually upload that 47MB folder to Github. The problem is I still end up with a bunch of 47MB folders on my local computer if i keep installing npm_modules for every project.

What do I do? Is it normal for node_modules to be such a big folder?

This is my Projects folder. There are like 70 small projects and maybe third have a node_modules folder (do the calculations :wink:) :

Jesus. So do you just add 500 MB every time you start a new project? i’m trying to figure out what developers normally do.

No, it’s total size of the whole Projects folder.
I counted and there are only 7 folders containing node_modules (I changed HDD recently). So each node_modules folder is 76MB in average.

i’m trying to figure out what developers normally do.

4 Likes

Oh haha. Ok, that’s not nearly as bad. I guess I did nothing wrong when first installing NPM. I’ll just have to live with my projects now taking up a ridiculous amount of space compared to before.

Be sure you are using v5 of npm (it’s much faster than v4) or you could try yarn.

There’s a npm package called pkglink that can significantly reduce the size of your node_modules folders by hardlinking the packages.

Here’s how much space I saved after first using it:

4 Likes

Looks promising, will definitely check out so I can reduce the space! Thank you!

You should check out nodx, it’s a real-time dependency resolver, it only extracts the files your script needs, and it keeps the files in a root directory, so no more duplicate files/dependencies.

1 Like

https://pnpm.js.org/

The size of node_modules is the source of many memes. Yes, this is normal. Is it good? No. But it’s the state of Node development right now.

When I’m developing, I tend to install with the -g (or global) flag. If I am using the package in multiple projects, it will look first in the global repository before adding to the local one.

That said, for each build, yeah - you’d end up with a sizeable node_modules.