grandchef / escpos-buffer

Library to generate buffer for thermal printers.
MIT License
51 stars 16 forks source link

escpos-buffer-web with Angular and WebUSB #36

Closed blue-predator closed 1 year ago

blue-predator commented 1 year ago

While testing this out I get: Error: Failed to execute 'open' on 'USBDevice': Access denied.

Worked around this by installing the Zadig USB driver, but then I get: ReferenceError: Buffer is not defined

yelhouti commented 1 year ago

I am getting the same issue, buffer is not defined.

it should normally be fixed by:


    new webpack.ProvidePlugin({
      Buffer: ['buffer', 'Buffer'],
    }),

config.resolve.fallback = {
    buffer: require.resolve('buffer/'),
}

I fixed it by adding:

import buffer from 'buffer';
(window as any).Buffer = buffer.Buffer;

in polyfills.ts which is imported in index.html

This was enough to make it work, but it has similar node issues to the ones found in escpos, which has more advanced functions so I am switching back to that