Sec-ant / barcode-detector

A Barcode Detection API polyfill that uses ZXing-C++ WebAssembly under the hood.
https://www.npmjs.com/package/barcode-detector/v/latest
MIT License
100 stars 7 forks source link

Can this library runs on Node.js ? #89

Closed GreenFlag31 closed 2 months ago

GreenFlag31 commented 3 months ago

Hi,

I have multiple times tried to make it work in a Node.js environnement but unsucessfully. There is a part in the readMe "Recommended Usage with Node + ESM", so is this possible?

If it's possible, can you provide a simple example?

Thanks in advance

Sec-ant commented 2 months ago

Hi, apologize for the late response.

This lib is meant to be used as a polyfill of the Barcode Detection API, which is a Web API and requires other Web and DOM APIs like canvas, DOMRectReadOnly, etc. Unless they're also properly polyfilled (which may also introduce significant performance loss), this lib is not likely to be used in node.

There is a part in the readMe "Recommended Usage with Node + ESM", so is this possible?

This is for building not running.

If you want to run barcode detections in other JS runtimes, you can check out the lower-level zxing-wasm project this lib depends on, which also provides more control options.