Hacker News new | ask | show | jobs
by jannes 2838 days ago
I wish there was something I could do about reducing the contents of the node_modules folder instead of hiding the files somewhere else on disk.

It angers me how many dependencies very simple projects amass.

4 comments

This change will reduce the size node_modules uses up (10 or more times).

pnpm saves one version of a package only ever once on a disk and node_modules consume drastically less space

here's an article about how much less disk space is used by pnpm. This concept will probably come with the same disk space savings http://www.andrewconnell.com/blog/npm-yarn-pnpm-which-packag...

but this concept is fresh, pnpm already works;)

It's actually relatively easy, I've recently written a non-trivial project with exactly 2 dependencies.

You just need to forgo all the conveniences the ecosystem provides and write stuff yourself instead.

Node.js or the browser have everything you need.

I've been trying to clean up my excess node modules and found that when building a web-socket app, you don't need express (native http works fine) and you don't even need socket.io (unless your project needs to work on IE 9 or less) It's hard to find examples so I wrote one: https://github.com/chrisbroski/bare-socket
Bringing packages into your work is your own choice. You should always be doing an evaluation of the benefit given by a package vs. the bloat it brings to your project. For many packages, it is worth it. But if you are in the habit of installing a package just to avoid writing a widget in your UI or writing some helper functions, then... yes, your projects will amass dependencies quickly.
My main complaint is probably about webpack and its dependencies. Unfortunately, it seems to be the accepted standard bundler. The benefits of hot module replacement are too nice to forego easily.
The ridiculous amount of dependencies in webpack is one of the major reasons I went for rollup. I refuse to install anything that depends on is-odd.
Not sure that webpack still depends on `is-odd` (at least not directly). Note that `is-odd` depends on `is-number` facepalm. Some people in this world seem to think their purpose is to create as many JS modules as possible.