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

BigInt error in production build, works fine in dev mode #11705

Open
kayhhh opened this issue Dec 2, 2021 · 4 comments
Open

BigInt error in production build, works fine in dev mode #11705

kayhhh opened this issue Dec 2, 2021 · 4 comments

Comments

@kayhhh
Copy link

kayhhh commented Dec 2, 2021

Describe the bug

Adding the following line causes an error in a site built with react-scripts build, but works fine with react-scripts start

image
image

Did you try recovering your dependencies?

yes

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

Environment Info:

current version of create-react-app: 4.0.3
running from C:\Users\lain\AppData\Local\npm-cache_npx\c67e74de0542c87c\node_modules\create-react-app

System:
OS: Windows 10 10.0.19042
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Binaries:
Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.1.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.41)
Internet Explorer: 11.0.19041.1202
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 4.0.3 => 4.0.3
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

  1. run npx create-react-app .
  2. add const TEST = 2n ** 3n; to the top of index.js
  3. run yarn build and serve build to see the error
  4. run yarn start to see it work correctly

Expected behavior

The page loads without error.

Actual behavior

The page does not load, there is an error in the console.

Reproducible demo

https://github.com/0xlain/cra-bug

@binkiebinkie
Copy link

binkiebinkie commented Dec 30, 2021

I was encountering this issue and I was able to overcome it by installing the @babel/plugin-syntax-bigint package. So I ran yarn add @babel/plugin-syntax-bigint, then in my babel.config.json file I added it to the plugins array like so:

{
  "plugins": ["@babel/plugin-syntax-bigint"]
}

Also, wherever you are deploying it to don't forget to clear your cache/delete node_modules

https://babeljs.io/docs/en/babel-plugin-syntax-bigint

@banool
Copy link

banool commented Jan 9, 2023

That fix didn't work for me unfortunately. @0xLain did you ever figure out a solution to this issue?

@kayhhh
Copy link
Author

kayhhh commented Jan 12, 2023

That fix didn't work for me unfortunately. @0xLain did you ever figure out a solution to this issue?

Nope, sorry.

@banool
Copy link

banool commented Jan 12, 2023

I found a fix in the end, instead of 2n ** 3n I did Math.pow(2n, 3n).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants