react-native: ReferenceError: Can't find variable: BigInt
I am trying to use the library which I used at web frontend development.
But when I am trying to use that library, it says
ReferenceError: Can't find variable: BigInt
BigInt
is a javascript built-in library, and I am not sure why React Native does not support, or React native does not support all new features of ES2020?
Binaries: Node: 12.15.0 Yarn: 1.22.0 npm: 6.13.4 Watchman: 4.9.0 SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 IDEs: Android Studio: 3.5 AI-191.8026.42.35.6010548 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 react-native: 0.61.5
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (2 by maintainers)
NOOO VERY BAD @Stalebot
Need a solution for this. I am also facing it.
I m having same issue is there any solution
Same issue here. don’t know what reason for that.
If you are still having this problem, here is how I solved it.
You are importing a package somewhere that requires BigInt as a dependency. For the most part RN uses JavaScriptCore which may not have the support of BigInt.
Okay, so one of your dependencies requires Bigint and it needs to be shim’ed. Your project probably relates to crypto and you are probably using rn-nodeify to shim the packages that you need. You have a
shim.js
file at the root of your project.1. Add big-integer to your list of dependencies:
2. Add a reference in shim.js
In your
shim.js
file, check if BigInt is undefined and if so assign it to the package you just installed:See this commit for the implementation.
update Aug 13, 2021: Updated to use the correct package import, sorry about that.
@stalebot @cpojer please consider reopening this one. to me it’s about upgrading to higher JSC version?
@jessgusclark Thanks, that worked!