Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

BigInt in node 12 (v12.22.12)

I’d like to use BigInt with node 12.22.12. It works fine in the REPL but in my script I need to "require" it. I tried things like const BigInt = require('BigInt') or require('node:bigint') and different mixes but it’s not working…

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

BigInt is a core part of the JS language (built into the interpreter itself). You don’t require() it. You can just use it as in:

let x = BigInt("9007199254740991");
let y = 9007199254740991n;

console.log(x, y);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading