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

What happened?

While trying to use jose (there https://github.com/PrismarineJS/prismarine-auth/blob/27b324544cacf518023381fe00705c919a95bf4a/src/TokenManagers/XboxTokenManager.js#L8)

we get a ReferenceError: TextEncoder is not defined

See https://github.com/PrismarineJS/node-minecraft-packets/runs/4087042559?check_suite_focus=true

Version

4.1.4

Runtime

Node.js

Runtime Details

node v14.15.1

Code to reproduce

Running this kind of code https://github.com/PrismarineJS/prismarine-auth/blob/27b324544cacf518023381fe00705c919a95bf4a/src/TokenManagers/XboxTokenManager.js#L22 in a jest test

see https://github.com/PrismarineJS/prismarine-auth/issues/10#issuecomment-943371074

I don’t completely get the relationship between jest and jose, but this doesn’t seem to be fully fixed

  • I have searched the issues tracker and discussions for similar topics and couldn’t find anything related.
  • I agree to follow this project’s Code of Conduct

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
panvacommented, Nov 8, 2021

@panva is there any solution with testEnvironment : jsdom ? in my project, if i change the testEnvironment to node, all tests will be error.

I’m not going to invest time in solving jsdom/jest issues not introduced here. See https://github.com/jsdom/jsdom/issues/2524 for possibly finding a workaround.

0reactions
holylovelqqcommented, Nov 8, 2021

@panva is there any solution with testEnvironment : jsdom ? in my project, if i change the testEnvironment to node, all tests will be error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: TextEncoder is not defined - Stack Overflow
A text encoder for Node.js can be found in the util module. You can access it like so: const util = require('util'); const...
Read more >
TextEncoder is not defined #209 - jsdom/whatwg-url - GitHub
You need to provide an example that only uses whatwg-url, no other packages, that we can run with node test.js . 👎 34...
Read more >
TextEncoder is not defined | NodeJs | MongoDB | Solved
TextEncoder is not definedReference ErrorPath for required filenode_modules/whatwg-url/encoding.jsThanks# TextEncoder #mongodb #nodejs.
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 >
TextEncoder is not defined Node.js with mongoose-mongodb
Coding example for the question ReferenceError: TextEncoder is not defined Node.js with mongoose-mongodb.
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