question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Okx getBalance causing Cannot convert a BigInt value to a number for npm build

See original GitHub issue

Occurs after running npm run build and using OKx to getBalance. Producing the following:

  Uncaught (in promise) TypeError: Cannot convert a BigInt value to a number
      at Math.pow (<anonymous>)
      at e.value (2.eb030928.chunk.js:2:58127)
      at Function.value (2.eb030928.chunk.js:2:60075)
      at r.value [as parse_balance] (2.eb030928.chunk.js:2:34003)
      at r.value [as parse_trading_balance] (2.eb030928.chunk.js:2:1264692)
      at r.value [as parse_balance_by_type] (2.eb030928.chunk.js:2:1264145)
      at r.<anonymous> (2.eb030928.chunk.js:2:1265638)
      at d (2.eb030928.chunk.js:2:1571787)
      at Generator._invoke (2.eb030928.chunk.js:2:1571540)
      at Generator.next (2.eb030928.chunk.js:2:1572150)

I am working on a browser extension using react, so I run npm run build and then load the extension into edge. This error doesn’t occur when using npm start and also occurs on older versions.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
baebranchcommented, Feb 9, 2022

Seems its browser compatibility settings for production. Using the following in package.json resolved it:

"browserslist": {
    "production": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }

Thank you for the assistance.

1reaction
kroitorcommented, Feb 9, 2022

It’s not really an issue with the CCXT code, it’s more like an issue with how create-react-app treats JavaScript’s operators:

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: can't convert BigInt to number - MDN Web Docs
The JavaScript exception "can't convert BigInt to number" occurs when an arithmetic operation involves a mix of BigInt and Number values.
Read more >
Conversion from 'BigInt' to 'number' is not allowed on react ...
I've developed UI using create-react-app. ... npm run build it's throwing the error `Conversion from 'BigInt' to 'number' is not allowed.
Read more >
The Essential Guide To JavaScript's Newest Data Type: BigInt
The BigInt data type aims to enable JavaScript programmers to represent integer values larger than the range supported by the Number data type....
Read more >
BigInt in JavaScript - GeeksforGeeks
This has various uses where operations on large numbers are required. Syntax: BigInt( number ) or Appending n to end of an integer...
Read more >
Enabling Filecoin interoperability with Cosmos Ecosystem
Sonr is building a light-weight trustless Filecoin bridge to its ... Okx getBalance causing Cannot convert a BigInt value to a number for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found