• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

639
Views
ReferenceError: TextEncoder no está definido al importar la biblioteca jsdom

Tengo estos dos archivos:

prueba.js :

 const jsdom = require("jsdom"); const hello = () => { console.log("hello!"); }; module.exports = { hello };

y

servidor.js :

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

estructura de directorios :

 myprojectfolder backend src stuff test.js server.js

Cuando ejecuto server.js obtengo el error ReferenceError: TextEncoder is not defined :

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

Si const jsdom = require("jsdom"); línea de test.js , server.js funciona bien y sin errores (muestra hello ).

¿Por qué sucede y cómo lo soluciono (mientras aún puedo importar y usar jsdom dentro test.js ?).

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error