question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: TextEncoder is not defined

See original GitHub issue

Relative from: https://github.com/Automattic/mongoose/issues/10713

In https://github.com/jsdom/whatwg-url/blob/master/src/encoding.js line 2 says:

"use strict";
const utf8Encoder = new TextEncoder();
const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });

But node show an error message:

/app/node_modules/whatwg-url/dist/encoding.js:2
const utf8Encoder = new TextEncoder();
                    ^

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

My node version:

$ node -v
v14.17.5

$ npm -v
6.14.14

The version in package.json of dependency is:

{
  "_from": "whatwg-url@^9.1.0",
  "_id": "whatwg-url@9.1.0",

I installed from mongoose package but have last version of whatwg-url package.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

41reactions
domeniccommented, Sep 12, 2021

You need to provide an example that only uses whatwg-url, no other packages, that we can run with node test.js.

22reactions
Unrasendcommented, Dec 13, 2021

The same issue on the nodejs v16.13.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: TextEncoder is not defined - Stack Overflow
This issue occurs in node 10 or lower version only. To resolve this issue upgrade node version to 12 or higher and then...
Read more >
Node.js TextEncoder - GeeksforGeeks
The TextEncoder class does not inherit any property. Only one property is defined which is: TextEncoder.prototype.encoding: It is a read-only ...
Read more >
const utf8Encoder = new TextEncoder(); mongoose
/app/node_modules/whatwg-url/dist/encoding.js:2 const utf8Encoder = new TextEncoder(); ^ ReferenceError: TextEncoder is not defined at Object.
Read more >
Javascript – ReferenceError: TextEncoder is not defined
I'm writing a simple addon in Firefox – 24, on Linux. I get the error: ReferenceError: TextEncoder is not defined. when I do:...
Read more >
Shopify-cli app "TextEncoder is not defined" error
... from /home/worm/Shopify_apps/seo-dev/.env ┃ (node:63571) UnhandledPromiseRejectionWarning: ReferenceError: TextEncoder is not defined.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found