I tried to follow the instructions in the Introduction to require and debug it with the Module require debugger but I’m new to JavaScript, that information wasn’t of much help.
Why can’t I import the package?
I tried to follow the instructions in the Introduction to require and debug it with the Module require debugger but I’m new to JavaScript, that information wasn’t of much help.
Why can’t I import the package?
Luckily they have a web version but not well described in the package.json
you can import it linking the web version
bigDecimal = await require('js-big-decimal/dist/web/js-big-decimal.min.js').catch(
() => window.bigDecimal
)
Thank you! That worked.
Could you explain what do you mean by “web version”? And why my original attempt was not successful?
@otaviocv when you compile a js library there are different targets, most common use of npm library is a nodejs import system that is different from the way your browser imports js code. If you look their webpack config you can see that they’re bundling it for node and for the web. https://github.com/royNiladri/js-big-decimal/blob/master/webpack.config.js#L12-L17. Observable uses d3-require
https://github.com/d3/d3-require to import libraries. It looks for package.json
meta data, in your js-big-decimal
the only info there is about "main": "dist/node/js-big-decimal"
node version which seems incompatible with the browser.