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

256
Views
Node.js and node_modules are less a TextEncoder within whatwg-url

I am attempting to run a set of files, and this error keeps popping up. I ran a separate set of files, loading a rest API to my localhost and that worked without error, but switching back to the first set of files still ends in the follow error:

const utf8Encoder = new TextEncoder();
                    ^

ReferenceError: TextEncoder is not defined
    at Object.<anonymous> (devel/node_modules/whatwg-url/dist/encoding.js:2:21)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (devel/node_modules/whatwg-url/dist/url-state-machine.js:5:34)
    at Module._compile (internal/modules/cjs/loader.js:778:30)

I have attempting to reinstall node.js, as well as update and manually delete the modules that are calling for this TextEncoder. The differences in required modules includes 'mongodb' and and 'csv-parse', which were on my personal machine, but not my office machine. Before I 'npm install ...' these two modules, the error appeared, so I then install the two modules, yet the error still persists. I also updated nodejs and again the error was the same. Any ideas on how to fix this so I can run my code?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I figured it out, it had to do with my mongodb and node_modules unbalanced connectivity, where I went to `/node_modules/whatwg-url/dist/encoding.js and imported the libraries for the TectEncoder and Text Decoder. The other way this can be fixed is at the top of the files using mongodb, insert...

global.TextEncoder = require("util").TextEncoder; global.TextDecoder = require("util").TextDecoder;

Either way fixes the compatibility issue.

about 4 years ago · Juan Pablo Isaza Report
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!