qrcode-with-logos icon indicating copy to clipboard operation
qrcode-with-logos copied to clipboard

Error "require is not defined" using the npm package

Open mginod opened this issue 7 months ago • 3 comments

Hello,

I'm using your (great) package version 1.0.5 in a Laravel project. My assets are bundled using Vite. After building my assets for prod, I have an error "require is not defined" in my console. I tracked down the error to this code:

// import QRCode from "qrcode"
var QRCode = require("qrcode");

in lib/qrcode-with-logos.esm.js

When editing directly this file in my node_modules and using the commented import, it works just fine.

I checked in the repo and there is a pull request https://github.com/zxpsuper/qrcode-with-logos/pull/15 that mentions this.

Is this something I can somehow fix on my part or should it be changed in the npm package?

Thank you for looking into this!

mginod avatar Nov 17 '23 12:11 mginod