keichi / binary-parser

A blazing-fast declarative parser builder for binary data
MIT License
864 stars 134 forks source link

TextDecoder is not defined #204

Closed mjmoron closed 2 years ago

mjmoron commented 2 years ago

Trying to run TCP and IP example: "node tcp.js", the following error is generated:

ReferenceError: TextDecoder is not defined at Parser.compile (/home/mjmoron/Documentos/Research/TLC/binary-parser/lib/binary_parser.js:630:143) at Parser.parse (/home/mjmoron/Documentos/Research/TLC/binary-parser/lib/binary_parser.js:678:18) at Object. (/home/mjmoron/Documentos/Research/TLC/binary-parser/example/tcp.js:25:23) 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 Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19)

Please, could you clarify what is the reason?

Thanks in advance, María

keichi commented 2 years ago

Hi María, what is the node version you are using? We support node 12 or higher.

mjmoron commented 2 years ago

I have upgraded to v12.22.12 and now it works. Thank you very much!

g-otn commented 1 month ago

In case someone stumbles into this issue because their environment doesn't support TextEncoder, (e.g Hermes https://github.com/facebook/hermes/issues/948, used in React Native) you can use fast-text-encoder as a polyfill.