dimanche 6 décembre 2020

Why does reactjs say module not installed when importing a third party script?

I am working on a React web application where I need a QR code scanner. I have followed this example. It instructs to a add a script tag in the index html file, then creates a component out of that script and afterwards renders that component.

Now the problem is that when I do it with separate files for the components and the index.html, it says that Html5QrcodeScanner (which is a class of the library) is undefined. So I imported the script at my component as well like: import Html5QrcodeScanner from 'html5-qrcode'. But then it says the module is not installed, while it is installed and listed in my package.json file.

Does anybody have an idea what I should do to get it working?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire