Sleavely / Bark-JS

🔬 Parse barcode inputs 🏷️ in a unified GS1-128 format 📦🌐
Other
28 stars 8 forks source link

Error on parsing even the example #13

Closed codeyogi911 closed 3 years ago

codeyogi911 commented 3 years ago

Hello, I was trying your library to parse GS1 codes in a react-native project. But even running the example gives me the following error. IMG_2007

Sleavely commented 3 years ago

That's odd. Could you provide which bark-js version you are using and the original barcode string (or a photo) you are attempting to parse?

Sleavely commented 3 years ago

On second thought I think it may be bundling thing since Bark never declares a _this variable. What does your Babel config look like and what version of babel are you using?

I think it's related to how this works differently depending on the type of module and environment your code is running in. In Node, this by default refers to the exports object, but when you transpile it Babel might be treating bark-js as an ES6 module which don't have the same this by default. You can get around this by tweaking your Babel config. This answer explains a bit more in depth and possible workarounds: https://stackoverflow.com/a/34983495/354776

Sleavely commented 3 years ago

I'm closing this since there is not much I can do to troubleshoot further without additional information. Leave a comment or open a new issue if there's anything I can do to help 👋