quaggaJS
quaggaJS copied to clipboard
Uncaught TypeError: y[e] is not a constructor
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);
}); }
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.
Seems like you mispelled "ean_readerz", can you try with "ean_reader" instead ? It has fixed the error for me :)
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.
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();
});
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