Ethers Version
5.7.0, 5.0.9
Search Terms
atob, base64
Describe the Problem
When starting my react-native project, I get one of the following errors (depending on environment):
ReferenceError: Can't find variable: atob
ReferenceError: Property 'atob' doesn't exist
Here are the full lines from the Metro console:
- From an existing project:
[Sun Oct 23 2022 13:44:49.144] ERROR ReferenceError: Can't find variable: atob
- From a new project:
ERROR ReferenceError: Property 'atob' doesn't exist, js engine: hermes
After that line, there are other errors that result from this, eg. Invariant Violation: "EndorserMobile" has not been registered. or Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication().
Here is the error that shows in an Android simulator:

I have not yet determined if it's a problem in iOS.
The most recent version I've tested is v 5.7.0 because that's the version available on npmjs.com; I'll invest more time and testing if this is a valid bug.
The code in the snippet shows the problem in a totally new environment, using asdf to set up the language tooling. (I also get it after cloning and starting this project, but that uses older versions of these libraries.)
Code Snippet
asdf global ruby ruby 2.7.5
npx react-native init testEthers --template react-native-template-typescript --npm
cd testEthers
asdf local java zulu-11.60.19
npm run android
// The app works in this state.
npm install @ethersproject/base64
// Now insert JavaScript code using base64 into App.tsx after the other imports, for example the following which is the first code snippet from https://www.npmjs.com/package/@ethersproject/base64
import * as base64 from "@ethersproject/base64";
let encodedData = "...";
let data = base64.decode(encodedData);
console.log(data);
// Then hit 'r' in the Metro window to reload the app and see the error.
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer), React Native/Expo/JavaScriptCore
Environment (Other)
No response
Ethers Version
5.7.0, 5.0.9
Search Terms
atob, base64
Describe the Problem
When starting my react-native project, I get one of the following errors (depending on environment):
ReferenceError: Can't find variable: atobReferenceError: Property 'atob' doesn't existHere are the full lines from the Metro console:
[Sun Oct 23 2022 13:44:49.144] ERROR ReferenceError: Can't find variable: atobERROR ReferenceError: Property 'atob' doesn't exist, js engine: hermesAfter that line, there are other errors that result from this, eg.
Invariant Violation: "EndorserMobile" has not been registered.orInvariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication().Here is the error that shows in an Android simulator:

I have not yet determined if it's a problem in iOS.
The most recent version I've tested is v 5.7.0 because that's the version available on npmjs.com; I'll invest more time and testing if this is a valid bug.
The code in the snippet shows the problem in a totally new environment, using asdf to set up the language tooling. (I also get it after cloning and starting this project, but that uses older versions of these libraries.)
Code Snippet
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer), React Native/Expo/JavaScriptCore
Environment (Other)
No response