ericblade / quagga2

An advanced barcode-scanner written in Javascript and TypeScript - Continuation from https://github.com/serratus/quaggajs
MIT License
765 stars 85 forks source link

Cannot find name 'Buffer' on Quagga2 type-definitions #509

Closed MasterDataBase closed 1 year ago

MasterDataBase commented 1 year ago

Hi all

I'm start using Quagga, and facing some problem after install Quagga on my Angular project.

And after the tring to import the library import Quagga from '@ericblade/quagga2';

I'm facing the following problem: Error: node_modules/@ericblade/quagga2/type-definitions/quagga.d.ts:784:33 - error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Trynpm i --save-dev @types/nodeand then add 'node' to the types field in your tsconfig.

I tried to install the @types/node and also insert the Type:node in the tsconfig file, but without luck, someone can point me to the right direction?

github-actions[bot] commented 1 year ago

Thank you for filing an issue! Please be patient. :-)

MasterDataBase commented 1 year ago

It seems to work now, the fix in my case was to:

yogeshgadge commented 6 months ago

It seems to work now, the fix in my case was to:

  • Install the types/node npm i --save-dev @types/node
  • Add in the tsconfig.app.json the value "types": ["node"] in the compilerOptions object

Not sure if this is a good workaround to add "types": ["node"] to the tsconfig.app.json If you are targeting browser app we need something better than allowing 'node'

ericblade commented 6 months ago

Thanks for bringing this back up. Decent tools are available now to probably replace the use of Buffer type in here. https://github.com/ericblade/quagga2/issues/538