admin管理员组

文章数量:1391960

I'm using react native 0.72.4

I'm getting this error: Reference Error: Property 'Text Encoder' doesn't exist at multiple places in my app. I didn't use it explicitly but my npm packages like qr-code-svg uses this package.

I don't know what Text Encoder is or where it is used .. i don't know why all of it occurs suddenly.

I'm using react native 0.72.4

I'm getting this error: Reference Error: Property 'Text Encoder' doesn't exist at multiple places in my app. I didn't use it explicitly but my npm packages like qr-code-svg uses this package.

I don't know what Text Encoder is or where it is used .. i don't know why all of it occurs suddenly.

Share Improve this question asked Aug 8, 2024 at 12:04 VIGNESH KUMARANVIGNESH KUMARAN 632 silver badges7 bronze badges 2
  • This question is similar to: Expo React Native Can't find variable: TextDecoder. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – user18309290 Commented Aug 8, 2024 at 13:48
  • Upgrading React Native to a version that includes TextEncoder will fix this. Otherwise, what's happening is you likely have something that's trying to access TextEncoder like it's in a browser. You can try exlcuding qr-code-svg from loading using Metro's blocklist if you can't remove it. – Slbox Commented Feb 12 at 3:35
Add a ment  | 

3 Answers 3

Reset to default 5

this worked for me using same react native 0.72.4

install text-encoding using npm install --save text-encoding --legacy-peer-deps

then import it everywhere you have imported the qrcode like so import 'text-encoding';

sample of how your code should look like when done with the install

import QRCode from 'react-native-qrcode-svg';
import 'text-encoding';

hope this helps!

They have fixed this issue with version 6.3.2

Update to this version and everything should work fine.

Ref:

  1. https://github./grgia/react-native-qrcode-svg/issues/199
  2. https://github./grgia/react-native-qrcode-svg/pull/200

Package text-encoding is no longer maintained. You should install a polyfill.

npm install text-encoding-polyfill

And include it at the top of your project.

// index.js
import 'text-encoding-polyfill'

本文标签: javascriptReferenceError Property 39TextEncoder39 doesn39t existStack Overflow