jsdom / whatwg-url

An implementation of the WHATWG URL Standard in JavaScript
https://jsdom.github.io/whatwg-url/
MIT License
371 stars 94 forks source link

ReferenceError: TextEncoder is not defined #196

Closed ghuser004 closed 3 years ago

ghuser004 commented 3 years ago

A basic hello world level application in nodejs causes this error. See the call stack:

user@2267cf4dbfae:~/data/node_modules/whatwg-url$ node ~/data/index.js
/home/user/data/node_modules/whatwg-url/dist/encoding.js:2
const utf8Encoder = new TextEncoder();
                    ^

ReferenceError: TextEncoder is not defined
    at Object.<anonymous> (/home/user/data/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> (/home/user/data/node_modules/whatwg-url/dist/url-state-machine.js:5:34)
    at Module._compile (internal/modules/cjs/loader.js:778:30)

I'm quite surprized this has slipped by. I don't know why this default install of node and whatwg-url fails to work but its causing HUGE problems for me. Please identify the cause and FIX.

nodejs version is 10.19.0 whatwg-url version is: 9.1.0

domenic commented 3 years ago

This issue does not follow the issue template, so we cannot help.