serratus / quaggaJS

An advanced barcode-scanner written in JavaScript
https://serratus.github.io/quaggaJS/
MIT License
5.06k stars 978 forks source link

How to use 1.0.0-beta.2? #152

Closed erik-kallen closed 6 years ago

erik-kallen commented 7 years ago

I am sorry if this is a stupid question, but I have this code, built with webpack:

import Quagga from 'quagga';

export default class Barcodescanner extends React.Component<PropType, void> {
  componentDidMount() {
    const element = this.refs.elem;
    console.log(element, Quagga);
    Quagga.init({
      inputStream : {
        name : 'Live',
        type : 'LiveStream',
        target: element    // Or '#yourElement' (optional)
      },
      decoder : {
        readers : ['ean_reader']
      }
    });
  }
}

On the line with Quagga.init, I get an exception saying that _quagga2.default.init is not a function, which is true. When I check src/quagga.js, it seems that what is actually exported is an object with properties fromSource, fromConfig, decoder, etc. If I use the pre-built quagga, everything works fine. How can I use the source distribution?

Edit: Turns out I was wrong and the pre-built version that works is 0.11.5, so 1.0.0-beta.2 does not work for me at all.

ericblade commented 6 years ago

@erik-kallen are you able to comment if this problem was solved in future versions?

erik-kallen commented 6 years ago

No, sorry, I have moved on from that project

ericblade commented 6 years ago

Thanks for getting back, erik, trying to clean up the issues page here after a period with little maintenance. :-)

I'm going to go ahead and close this, as there doesn't seem to be any similar issues, so I'm thinking either it was fixed inbetween the issue being filed and now, or it was somehow a mis-use. I guess if we see it again, we can re-open