Wow, so maybe instead of a node_modules folder, npm should use a node_modules.db?
That would be amazing! To work though, you'd need some kind of interface to actually access the contents. I guess that's doable, but not ideal. Someone else posted libsqlfs, which is FUSE Sqlite file system, and should do the job...not exactly plug-and-play though, and presumably wouldn't work on Windows (maybe on WSL tho?)
With a FUSE filesystem, you're still incurring the syscall overhead that's causing this performance disparity in the first case, plus now the kernel has to context-switch into the FUSEing process. So what would be 2 context switches for each syscall (program -> kernel -> program) now is 3 or 4 context switches (program -> kernel -> FUSE -> (kernel ->) program).
FUSE has some amazing usecases, but performance is none of them.