Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda