2

I need Tesseract in my project so first I used yarn add tesseract.js after that I used yarn add --dev @types/tesseract.js. When I try to use ng serve I get the following error:

ERROR in node_modules/tesseract.js/src/index.d.ts:98:60 - error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.

98     | CanvasRenderingContext2D | File | Blob | ImageData | Buffer;

Anyone knows how to fix this? Thanks in advance

CoryCoolguy
  • 1,065
  • 8
  • 18
Gavin Hartog
  • 31
  • 1
  • 5

2 Answers2

8

I was able to resolve this issue by adding types: ["node"] to the compilerOptions in tsconfig.app.json file.

{
  ...
  "compilerOptions": {
    ...
    "types": ["node"] // <-- This should do the charm.
  },
  ...
}
Harish
  • 714
  • 5
  • 11
0

I was having the same problem with my tesseract application and I tried this and it worked.

Source: cannot find name 'require' in angular 7(typescript 3.1.3)

  • 1
    Hi Host_Ghost, thank you for spending the time to answer a question here. In SO, it is usual to provide (at least in summary) the actual solution and then add the source link. Makes your insight findable by the SO search – stwissel Apr 09 '20 at 18:13