Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
How to link dynamic node modules without a file system?

Currently, I'm trying to develop a tool, that makes it possible to pack a JS-Module into tar-archive and then load it into Node.js dynamically and in-memory.

It does work perfectly, when importing a single JS-file that has no dependencies to other files. But when there are dependencies, I can't glue them together yet.

An example structure in the archive could look like this:

someArchive.tar.gz
- foo.js
- package.json
- lib
  - bar.js

The relationship between the two modules could look like this (foo.js):

import { something } from "./lib/bar.js";

To make it possible to use an archived JS-file in general, I'm using the "adm-zip"-npm-package, which allows me to deal with archives in-memory.

Important: I cannot use the file-system in any way for this project, unfortunately.

While the "adm-zip"-package enables me to handle the data itself, I am constructing the module-object on my own using the Module-Constructor:

const Module = module.constructor;
const m = new Module();
const moduleName = "<Filename relative to archive root>";
m.children = [ <the module-object from bar.js> ];
m._compile(<fooContentFromArchive>, moduleName);
m.path = <moduleName without filename>;
m.id = moduleName;
m.filename = moduleName;
return m;

As you can see, I already put the dependent module-object into the children-array of the superior module-object. As far as I understood, the children-array is containing dependent modules.

But unfortunately, it doesn't work.

I know, that what I am doing is very special and hacky, and especially using the file-system would make everything much easier, but as mentioned, I have the limitation, that I don't have access to the filesystem.

Also, I haven't found any npm-packages, that are enabling me to do solve the problem (If I get it working, I could create one).

Do you have any idea, what I could try?

Thank you in advance!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!