我的项目中需要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.
},
...
}
我的tesseract应用程序也遇到了同样的问题,我尝试了一下,结果成功了。
来源:找不到名称';要求';角度7(字体3.1.3(