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

Importing issues with the package #31

Closed temurih closed 3 months ago

temurih commented 9 months ago

Hey, I am trying to import your package but I am getting this error,

import QRCodeWithLogos from 'qrcode-with-logos';
new QRCodeWithLogos({...});

I am using NodeJS v16. Please let me know if you need more details.

Looks like you do have a default export, but I am not sure why its not working. https://github.com/zxpsuper/qrcode-with-logos/blob/master/src/index.ts#L62

TypeError: qrcode_with_logos_1.default is not a constructor
    at generateQrCode (..\src\promotion\qr\qr.controller.ts:18:33)
    at QRController.createQR (..\src\promotion\qr\qr.controller.ts:43:26)
    at ..\node_modules\@nestjs\core\router\router-execution-context.js:38:29       
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at ..\node_modules\@nestjs\core\router\router-execution-context.js:46:28       
    at ..\node_modules\@nestjs\core\router\router-proxy.js:9:17

Fixed with using require, but then I ran into this,

ReferenceError: document is not defined
    at new QrCodeWithLogo (..\node_modules\qrcode-with-logos\lib\qrcode-with-logos.common.js:298:34)
    at generateQrCode (..\src\promotion\qr\qr.controller.ts:19:33)
    at QRController.createQR (..\src\promotion\qr\qr.controller.ts:43:26)
    at ..\node_modules\@nestjs\core\router\router-execution-context.js:38:29       
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at ..\node_modules\@nestjs\core\router\router-execution-context.js:46:28       
    at ..\node_modules\@nestjs\core\router\router-proxy.js:9:17

I guess this is only browser-based, and you can't use it with Node?

zxpsuper commented 9 months ago

Hey, I am trying to import your package but I am getting this error,

import QRCodeWithLogos from 'qrcode-with-logos';
new QRCodeWithLogos({...});

I am using NodeJS v16. Please let me know if you need more details.

Looks like you do have a default export, but I am not sure why its not working. https://github.com/zxpsuper/qrcode-with-logos/blob/master/src/index.ts#L62

TypeError: qrcode_with_logos_1.default is not a constructor
    at generateQrCode (..\src\promotion\qr\qr.controller.ts:18:33)
    at QRController.createQR (..\src\promotion\qr\qr.controller.ts:43:26)
    at ..\node_modules\@nestjs\core\router\router-execution-context.js:38:29       
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at ..\node_modules\@nestjs\core\router\router-execution-context.js:46:28       
    at ..\node_modules\@nestjs\core\router\router-proxy.js:9:17

Fixed with using require, but then I ran into this,

ReferenceError: document is not defined
    at new QrCodeWithLogo (..\node_modules\qrcode-with-logos\lib\qrcode-with-logos.common.js:298:34)
    at generateQrCode (..\src\promotion\qr\qr.controller.ts:19:33)
    at QRController.createQR (..\src\promotion\qr\qr.controller.ts:43:26)
    at ..\node_modules\@nestjs\core\router\router-execution-context.js:38:29       
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at ..\node_modules\@nestjs\core\router\router-execution-context.js:46:28       
    at ..\node_modules\@nestjs\core\router\router-proxy.js:9:17

I guess this is only browser-based, and you can't use it with Node?

yes, it is only browser-based!😂