zxpsuper / qrcode-with-logos

A plugin for generating QR codes with a logo and styling.
https://zxpsuper.github.io/qrcode-with-logos
MIT License
137 stars 41 forks source link

Error "require is not defined" using the npm package #30

Closed mginod closed 3 months ago

mginod commented 9 months ago

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!

zxpsuper commented 9 months ago

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 #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!

I will fix it in next version. The fastest way to solve this problem is that copying qrcode-with-logos.esm.js file to your project and fix it . Editing directly this file in your node_modules is not a Reliable way.

magror commented 7 months ago

Hello, That updated version would be much appreciated! Is there an ETA? Thank you very much in advance :)

HoekWax commented 6 months ago

Hello @zxpsuper, same question as above, do you have an ETA for this ? Thanks

j-d-carmichael commented 3 months ago

This package is perfect for what I am looking for... but I am also hitting the same issue as above.

Any timeline on the new release?

j-d-carmichael commented 3 months ago

Forked and PR created: https://github.com/zxpsuper/qrcode-with-logos/pull/33

zxpsuper commented 3 months ago

This package is perfect for what I am looking for... but I am also hitting the same issue as above.

Any timeline on the new release?

release 1.0.6 has fix this issue.