fs-monkey icon indicating copy to clipboard operation
fs-monkey copied to clipboard

Incompatible with on-memfs node_modules?

Open DaryeDev opened this issue 6 months ago • 0 comments

I'm trying to isolate as much as possible on a Plugin system, on which I wanted to have only the node_modules necessary for that Plugin, along with the Plugin's files, on a memfs Volume.

I create my pluginVolume with new Volume(), make a folder there called node_modules and copy the Plugin's dependencies (for example, naudiodon-no-segfault-handler and bindings), and then call patchFs and patchRequire with that pluginVolume as argument.

Calling require("fs") after that correctly returns me a filesystem with the pluginVolume, but calling require("naudiodon-no-segfault-handler") returns an Uncaught Error: Cannot find module 'naudiodon-no-segfault-handler'.

Image

I wanted the modules inside the virtual node_modules, installed with npm outside the project's folder and copied into the Volume, to be resolved with just the name of the module, like the original require works with the node_modules folder on the project's dir.

Is there any way to accomplish what I'm talking about? Any help is greatly appreciated.

DaryeDev avatar Jul 02 '25 01:07 DaryeDev