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

144
Vistas
esbuild cannot resolve the Node.js module 'events'

One of my dependencies contains the following code

var EventEmitter = require('events').EventEmitter;

exports.EventEmitter = EventEmitter;
exports.mixin = mixin;

function mixin(Constructor) {
  for (var key in EventEmitter.prototype) {
    Constructor.prototype[key] = EventEmitter.prototype[key];
  }
}

I got the following error when trying to bundle everything into a file

$ npm run build


> gantt@0.0.0 build
> esbuild public/js/src/main.ts --bundle --minify --sourcemap --outfile=public/js/dest/bundled.js

 > node_modules/sharedb/lib/emitter.js:1:27: error: Could not resolve "events" (use "--platform=node" when building for node)
    1 │ var EventEmitter = require('events').EventEmitter;
      ╵                            ~~~~~~~~

1 error

I am targeting browsers, so it's impractical to have --platform=node. I discovered this issue when searching around, but the offending line is in a dependency, so I cannot simply edit its source to replace the CommonJS module import with an ES module import.

How can I point esbuild to the implementation of events?

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