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

184
Views
Dynamic module imports is empty when inside Docker

When I use await import(module) inside Docker the module is just an empty object. Outside of docker everything works as intended.

Node: v16.13.1
Docker: Docker version 20.10.7, build f0df350
Image: node:16

The Code:

import path from "path";

export const WorkerLoader = async () => {
    // import Worker from the public directory => copied from docker
    const here = "file://" + path.resolve("./worker/worker.js"); // worker.wasm.js & worker.wasm don't work in node
    const WorkerModule = await import(here);

    WorkerModule().then(callback); // no, its not a promise
}

If I log WorkerModule I get [Module: null prototype] { }. I've also tried to do it with WorkerModule.default but this is undefined.

I can't just simply change the code to a normal import because it need those exact functions to be present due to a shared code basis for web and nodejs, where I use module-alias to make my own implementations of modules, that were designed for the web.

Edit: The worker.js file has at the end

if (typeof exports === 'object' && typeof module === 'object')
  module.exports = Worker;
else if (typeof define === 'function' && define['amd'])
  define([], function() { return Worker; });
else if (typeof exports === 'object')
  exports["Worker"] = Worker;
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!