Library loading error

Hey everyone,

This question is not a babylonjs question, however you are all very smart and i hope you can help me.

I am trying to use this library GitHub - MikeMcl/bignumber.js: A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
I have set it up by running npm install bignumber.js as well as
npm install @types/bignumber.js --save
then i added this script to my html file
<script src=“node_modules/bignumber.js/bignumber.min.js”></script>
then in my typescript files:
import BigNumber from “bignumber.js”;

Now this initially seems to work, as Visual studio Code recognizes it and tries to auto complete with it etc…
However when i try to run i get this error:

Unable to resolve bare specifier “bignumber.js”

So i have looked up this Unable to resolve bare specifier error and i dont fully understand. It seems that there is a error with the way i am importing the library. However i could not find any solutions to the problem. Here is the link to where i read that: Importing ES modules in browser does not work · Issue #7766 · openlayers/openlayers · GitHub

So i was wondering:

Any ideas how i can fix this so i could use bignumber.js? (Or know and other good library’s that can handle large floating point maths?)

Also it seems the playground is not working right now!

Hi @Rah, Indeed off-topic for babylonJs :stuck_out_tongue_winking_eye:

But It looks like it should be big-number, and not bignumber.

var BigNumber = require(‘big-number’);

<script src =“big-number.js”></script>

1 Like

hmmm, i cant use require, as im using systemjs.

Also Visual Studio Code auto completed bignumber.

Let alone the npm package has everything named bignumber.

Actually im sorry, i just noticed a typo in my origonal post. il update that now.

Hold on i think i messed something up…

Ok i updated the question with the correct information.

I am using bignumber.js not big-number.

Very sorry for the confusion

I’m rather clueless at the moment, but try these…

github page says .MJS

import BigNumber from “./bignumber.mjs”

and make sure you can access ‘node_modules/bignumber.js/bignumber.min.js’ on the client

1 Like

how could i check if i can access that file on the client side?

Ahh sorry nvm, you’re still in typescript…


as the client-side of course shouldn’t have access to node_modules folder at all.
If that’s not it, perhaps someone with more VS & typescript knowledge will come along :slight_smile:

1 Like