Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: Can't find variable: BigInt #28492

Closed
r2moon opened this issue Apr 2, 2020 · 22 comments
Closed

ReferenceError: Can't find variable: BigInt #28492

r2moon opened this issue Apr 2, 2020 · 22 comments
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@r2moon
Copy link

r2moon commented Apr 2, 2020

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

Screen Shot 2020-04-02 at 11 45 20 AM

@react-native-bot react-native-bot added Needs: Author Feedback Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. and removed Needs: Triage 🔍 labels Apr 2, 2020
@label-actions
Copy link

label-actions bot commented Apr 2, 2020

⚠️ Missing Environment Information
ℹ️ Your issue may be missing information about your development environment. You can obtain the missing information by running react-native info in a console.

@shpetimselaci
Copy link

Same issue here.
Do you think it has to do with the bundler?
Did you resolve it?

@r2moon
Copy link
Author

r2moon commented Apr 24, 2020

BigInt is one of the new feature of the ECMAScript 2020, and I think react native does not support latest ECMAScript.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Apr 24, 2020
@xiaods
Copy link

xiaods commented Apr 27, 2020

Same issue here.
don't know what reason for that.

@stale
Copy link

stale bot commented Jul 26, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 26, 2020
@stale
Copy link

stale bot commented Aug 2, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 2, 2020
@hsavit1
Copy link

hsavit1 commented Aug 27, 2020

NOOO VERY BAD @stalebot

@vitolipari
Copy link

I have the same issue

@natalyayyad
Copy link

Same Issue here!

@vitolipari
Copy link

Try to add the @babel/plugin-syntax-bigint plugin in your babel configuration file.

My babel.config.js file before

module.exports = {
  presets: ['module:metro-react-native-babel-preset']
};

My babel.config.js file now

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ["@babel/plugin-syntax-bigint"]
};

I fixed it in this way

@monaye
Copy link

monaye commented Nov 28, 2020

@vitolipari thank you for posting the possible solution. I tried adding the suggested plugin but still getting the same error. Would you mind sharing the npm list ?

@vitolipari
Copy link

@vitolipari thank you for posting the possible solution. I tried adding the suggested plugin but still getting the same error. Would you mind sharing the npm list ?

this is a part of my package.json file

"dependencies": {
    "react": "16.13.1",
    "react-native": "0.63.3",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/native": "^5.8.9",
    "@react-navigation/stack": "^5.12.6",
    "react-native-device-info": "7.2.1",
    "react-native-gesture-handler": "^1.8.0",
    "react-native-reanimated": "^1.13.2",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.15.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.13.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
}```

@gre
Copy link
Contributor

gre commented Dec 10, 2020

This should be addressed. It makes some library (like ripple-lib) to behave inconsistently depending on iOS / android.

@gre
Copy link
Contributor

gre commented Dec 10, 2020

@stalebot @cpojer please consider reopening this one. to me it's about upgrading to higher JSC version?

@david-gregorian
Copy link

I also have the same issue. Adding the @babel/plugin-syntax-bigint did not help.

System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 81.20 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.14.1 - /usr/local/bin/node
    npm: 6.14.6 - ~/.npm-global/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.7/11E801a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.3 => 0.63.3 
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native: 0.63.1

@vikil143
Copy link

I m having same issue is there any solution

@kjawadDeveloper
Copy link

Need a solution for this. I am also facing it.

@jessgusclark
Copy link

jessgusclark commented Apr 22, 2021

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:

yarn add big-integer

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:

if (typeof BigInt === 'undefined') global.BigInt = require('big-integer')

See this commit for the implementation.


update Aug 13, 2021: Updated to use the correct package import, sorry about that.

@ghaschel
Copy link

@jessgusclark Thanks, that worked!

@Jarrio
Copy link

Jarrio commented Aug 12, 2021

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:

yarn add @rsksmart/rns-resolver.js

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:

if (typeof BigInt === 'undefined') global.BigInt = require('big-integer')

See this commit for the implementation.

your solution got me past the big int issue, but it introduced another issue
image
Do you (or anyone else) happen to know how to deal with this? (I am merely pulling data from ccxt which is just an exchange api aggregator) so I don't really have control over the base code

@jessgusclark
Copy link

Hey @Jarrio, glad that moved you slightly forward. This error does not look to be related to the issue here, rather perhaps, data that is in an incorrect format from the API, or being converted incorrectly in your project (or dependency). I'd take a look at the stack, where this is happening. I wonder if the e+3 can't be parsed with the parseStringValue method?

@hildjj
Copy link

hildjj commented Sep 27, 2021

What version of JSC is react-native currently using? It looks like JSC does support BigInt now, at least the one on my box does. (MacOS 10.6, Safari 15.0)

@facebook facebook locked as resolved and limited conversation to collaborators Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests