Node.js: The browser doesn't support Webassembly.
ahmedEnosis opened this issue · 3 comments
I have tried to install the dynamsoft-javascript-barcode package using npm
and execute the example code provided here. It was throwing me the following error saying Webassembly
is not supported in the browser(As node doesn't naively support webassembly). I've also found this instruction to wrap the sdk for linux environment. But, I was wondering if there is a way where would could use the bar-code reader right of the bat skipping the manual build procedure.
Error:
Error: 'Constructor BarcodeReader(productKeys)': The browser doesn't support Webassembly.
at Error (native)
at then.a._loadWasmStatus (\path\to\project\dbr\dbr.min.js:63:430)
at \path\to\project\dbr\dbr.min.js:63:101
at Timeout._onTimeout (\path\to\project\dbr\dbr.min.js:15:423)
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)
@ahmedEnosis The dynamsoft-javascript-barcode is based on WebAssembly, which means you can use it on any platforms including Windows, Linux, macOS, and Raspberry Pi. Do you have an image file named sample.png
in your project folder?
We have provided a test image under node_modules\dynamsoft-javascript-barcode\samples\sample.png
. You can use it for testing Node.js code.
reader.decode('sample.png')
In addition, please get a trial license and update the following line in your code:
dbr.BarcodeReader.productKeys = 'LICENSE-KEY';
Here are my results:
@ahmedEnosis Note: the link https://www.codepool.biz/linux-barcode-sdk-node-javascript.html shares how to wrap the C++ barcode SDK (which is platform-dependent) for Node.js. It's totally different from dynamsoft-javascript-barcode.
@yushulx, thank you for your help. It turns out I was following the proper procedure in the code but, my node version that I was using (6.2.2) does not play well with webassembly
. So, I changed node version to 10.15.3
and everything seems to be working just fine.