quaggaJS icon indicating copy to clipboard operation
quaggaJS copied to clipboard

Uncaught TypeError: y[e] is not a constructor

Open Krsikapa00 opened this issue 5 years ago • 5 comments

I am getting this error every time I try to run the QuaggaJS code. I am not sure if I am using the method incorrectly or if there is a problem with the api and React or the browser. I would greatly appreciate the help.

My code where I include the Quagga method is:

componentDidMount() {

Quagga.init({
    inputStream: {
        name: "Live",
        type : "LiveStream",
        target: document.querySelector('#scanner-container'),
        constraints: {
            width: 640,
            height: 480,
            facingMode: "environment" // or user
        }
    },
    decoder: {
        readers : [ "ean_readerz"],
        debug: {
          showCanvas: true,
          showPatches: true,
          showFoundPatches: true,
          showSkeleton: true,
          showLabels: true,
          showPatchLabels: true,
          showRemainingPatchLabels: true,
          boxFromPatches: {
              showTransformed: true,
              showTransformedBox: true,
              showBB: true
          }
      }
    },
}, function(err) { 
    if (err) {
        return console.log(err);
    }
    console.log("starting scanning")
    Quagga.start();
});

Quagga.onDetected(function (result) {
  console.log("Barcode detected and processed : [" + result.codeResult.code + "]", result);

}); }

Krsikapa00 avatar Mar 15 '19 00:03 Krsikapa00

I suspect that you are running webpack on an already webpacked module, but I don't know that for sure. It's almost definitely something in your packaging setup, I'd say -- there's no code like that in the regular code base.

ericblade avatar Mar 15 '19 08:03 ericblade

Seems like you mispelled "ean_readerz", can you try with "ean_reader" instead ? It has fixed the error for me :)

AmauryLnd avatar Mar 25 '19 10:03 AmauryLnd

I also ran into this bug when I misspelled one of the strings that is passed to the readers object. In your example, as AmauryLnd pointed out, you have a spelling mistake. Could add better error handling to QuaggaJs to let the dev know when they're passing a key for the readers object that doesn't exist.

markdegroat avatar Jan 28 '20 22:01 markdegroat

having same problem, tried writing EAN_13 and ean_13

Quagga.init({
            inputStream : {
                name : "Live",
                type : "LiveStream",
                target: document.querySelector('#preview')
            },
            decoder : {
                readers : ["ean_13"]
            }
        }, function(err) {
            if (err) {
                console.log(err);
                return
            }
            console.log("Initialization finished. Ready to start");
            Quagga.start();
        });

well-it-wasnt-me avatar Aug 19 '21 22:08 well-it-wasnt-me

The most important property is `readers` which takes an array of types of
barcodes which should be decoded during the session. Possible values are:

- code_128_reader (default)
- ean_reader
- ean_8_reader
- code_39_reader
- code_39_vin_reader
- codabar_reader
- upc_reader
- upc_e_reader
- i2of5_reader
- 2of5_reader
- code_93_reader
- code_32_reader

ericblade avatar Sep 01 '21 09:09 ericblade