3

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

1
  • facing the same issue. Any solution that worked? Commented Jun 21, 2020 at 22:38

2 Answers 2

9

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.
  },
  ...
}
Sign up to request clarification or add additional context in comments.

Comments

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 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.