Fixing node_modules

There’s too many files, too many files
Making too many problems
And not much inodes to go ‘round
Can’t you see this is a land of node_modules?

All that’s needed to fix node_modules is to implement a random-access file format with a simple TOC header, so modules can be archived into single files each, or even a single file globally if needs be.

Good thing this lost technology has existed since the olden ages of the DOS era, so it should be easy for Node devs to get it done. Unless they become stricken by extreme stubbornitis, that is.

Instead of directly fishing a file from the filesystem, do this first:

  1. Did I already load this module’s TOC? No
  2. Does /node_modules/modulename-version.module exist? Yes
  3. Let’s load the TOC header in memory
  4. Match the requested file in the TOC
  5. Open the address
  6. Keep TOC in memory for further requests

BAM! Snail copy times fixed! Delete times fixed! Inode usage fixed! $MFT table not bloated! Unnecessary filesystem queries avoided! No more wasted allocation space! Antivirus scanning slowdowns cut down! Performance increased! Programmers happy! Carbon footprint reduced! World saved!

In fact, Electron already implemented this solution with ASAR archives, and it works exactly as it should. But Node needs this feature natively. There are a gorillion cli utilities that runs on Node, and they keep littering your filesystem for absolutely no reason.

The modules carrying executable binaries could be marked as non-compatible with single-file modules.

Add some cli commands to pack/unpack depending on necessity.

And done.

We shouldn’t have to use symbolic links, or webpack, or stupidly contrived workarounds.

Node.js has set itself as a standard, and should therefore take responsability in addressing these simple basic issues that cause annoyance to everyone in the tech field.