You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I struggled to find a good solution for implementing the barcode and QR code in the Node.js environment. I thought I can forget about everything after finding this library unless I moved part of my project to the Cloudflare Workers environment.
Well.. nothing worked anymore.
It just threw issues, that .toBuffer is not a function and that's all.
In the process of trying to solve this issue, I found some other libraries, that somehow do the job, but there were other issues, most of them related to the same differences from the Node.js and Workers environment.
Here, I will paste my function (if anyone else is looking for the solution):
Everything worked before well unless it came to const buffer = bwipjs.toBuffer(options);, where the error appeared.
Instead, I changed it to const buffer = bwipjs.toSVG(options); to output just an SVG.
It's important, to include additional import { Buffer } from 'node:buffer'; at the top (see cloudflare documentation: https://developers.cloudflare.com/workers/runtime-apis/nodejs/), so this const svgBase64 = Buffer.from(buffer).toString('base64'); does not throw another error. :)
--
That's working for me.
For the authors - I wanted you to suggest including additional sentences about the Workers, as at one moment I had the feeling, that I was the only one who is dealing with that. At one place I just read the sentence "Well, just don't do this to workers, it's not for everything".
Again - Thank you. :)
The text was updated successfully, but these errors were encountered:
m-muiznieks
changed the title
Bwipjs and Cloudflare Workers - suggestion to include additional information to documentation
Bwip-js and Cloudflare Workers - suggestion to include additional information to documentation
Apr 20, 2024
Did you look at the examples/threader.js code in the project? It demonstrates how to use with nodejs worker threads. Is there something about the cloudfare environment that is different than the standard node:worker_threads module?
Please tell me more about how you are creating the worker threads and communicating between the main thread and worker threads.
At first - thank you for your work.
I struggled to find a good solution for implementing the barcode and QR code in the Node.js environment. I thought I can forget about everything after finding this library unless I moved part of my project to the Cloudflare Workers environment.
Well.. nothing worked anymore.
It just threw issues, that .toBuffer is not a function and that's all.
In the process of trying to solve this issue, I found some other libraries, that somehow do the job, but there were other issues, most of them related to the same differences from the Node.js and Workers environment.
Here, I will paste my function (if anyone else is looking for the solution):
Everything worked before well unless it came to
const buffer = bwipjs.toBuffer(options);
, where the error appeared.Instead, I changed it to
const buffer = bwipjs.toSVG(options);
to output just an SVG.It's important, to include additional
import { Buffer } from 'node:buffer';
at the top (see cloudflare documentation: https://developers.cloudflare.com/workers/runtime-apis/nodejs/), so thisconst svgBase64 = Buffer.from(buffer).toString('base64');
does not throw another error. :)--
That's working for me.
For the authors - I wanted you to suggest including additional sentences about the Workers, as at one moment I had the feeling, that I was the only one who is dealing with that. At one place I just read the sentence "Well, just don't do this to workers, it's not for everything".
Again - Thank you. :)
The text was updated successfully, but these errors were encountered: