我的项目中需要 Tesseract,所以首先我使用了 yarn add tesseract.js
,然后我使用了 yarn add --dev @types/tesseract.js
。当我尝试使用 ng serve
时,出现以下错误:
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;
有人知道怎么解决吗?提前致谢
最佳答案
我能够通过将 types: ["node"]
添加到 tsconfig.app.json
文件中的 compilerOptions
来解决这个问题.
{
...
"compilerOptions": {
...
"types": ["node"] // <-- This should do the charm.
},
...
}
关于angular - 在 Angular 中安装 Tesseract.js 后找不到名称 'Buffer' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60322215/