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

739
Vistas
ReferenceError: TextEncoder is not defined when importing jsdom library

I have these two files:

test.js:

const jsdom = require("jsdom");

const hello  = () =>  {
  console.log("hello!");
};


module.exports = {
    hello
};

and

server.js:

const hello = require('./stuff/test');

hello.hello();

directory structure:

myprojectfolder
             backend
                    src
                       stuff
                           test.js
                       server.js

When I run server.js I get the ReferenceError: TextEncoder is not defined error:

/home/myusername/projects/myprojectfolder/node_modules/whatwg-url/lib/encoding.js:2
const utf8Encoder = new TextEncoder();
                    ^

ReferenceError: TextEncoder is not defined

If I remove const jsdom = require("jsdom"); line from test.js, server.js runs fine and without any errors (outputs hello).

Why does it happen and how do I fix it (while still being able to import and use jsdom inside test.js?).

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