question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using npm webpack with html5-qrcode

See original GitHub issue

Your demos are awesome but i’m struggling to get html5-qrcode working in my javascript.

Here is the most basic example i’m using after installing your library via npm.

require('html5-qrcode');

Html5Qrcode.getCameras().then(devices => {
    
    if (devices && devices.length) {
        let  cameraId = devices[0].id;

        const html5QrCode = new Html5Qrcode("reader");

        html5QrCode.start(
            cameraId,
            {
                fps: 10,
                qrbox: 250
            },
            qrCodeMessage => {

                console.log('QR Code detected');

            },
            errorMessage => {

                console.log('QR Code no longer in front of camera.');

            })
            .catch(err => {

                console.log('Unable to start scanning:');

            });

    }

}).catch(err => {

    console.log('error');

});

I’m loading the compiled javascript at the end of my page.

But I’m getting this error…

Uncaught TypeError: Cannot read property 'getCameras' of undefined

I’ve also tried using…

import Html5Qrcode from 'html5-qrcode';

But in the javascript file in my IDE, the function getCameras() says Cannot find declaration to go to

It is tricky to see the npm package code because it’s been minified and there is no src folder included in the npm package. Normally it most npm packages the src files are used and then the code is compiled later.

Am I missing a trick? can you please advise as I really want to start using this in my web app.

Many thanks

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mebjascommented, Oct 23, 2021

This should have been fixed in latest version - v2.1.0

Please reopen if this is still an issue.

0reactions
denguyen-tvitcommented, Jul 5, 2021

@joshmoto please make sure you loaded script successfully Screen Shot 2021-07-05 at 22 47 05

@dampee I succeed to use with ADM loading (because I use for Magento 2)

Screen Shot 2021-07-05 at 22 51 20
Read more comments on GitHub >

github_iconTop Results From Across the Web

html5-qrcode - npm
Use this lightweight library to easily / quickly integrate QR code, bar code, and other common code scanning capabilities to your web ...
Read more >
html5-qrcode webpack encore - Stack Overflow
I try use https://github.com/ ...
Read more >
Qrcode Scan with Reactjs - simbathesailor.DEV
I made use of html5-qrcode library for qrcode scanning. mebjas created this wrapper ... We will make use of two webpack plugins to...
Read more >
webpack/webpack - Gitter
I'm trying to pack a node.js application that makes use of config and js-yaml ... The html5-qrcode.js contains 2 classes (with no exports)...
Read more >
html5-qrcode - Bountysource
Using npm webpack with html5-qrcode $ 0. Created 1 year ago in mebjas/html5-qrcode with 5 comments. Your demos are awesome but i'm struggling ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found