我需要在我的项目中使用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;有人知道怎么解决这个问题吗?提前感谢
发布于 2020-06-22 06:44:59
我能够通过在tsconfig.app.json文件中的compilerOptions中添加types: ["node"]来解决这个问题。
{
...
"compilerOptions": {
...
"types": ["node"] // <-- This should do the charm.
},
...
}发布于 2020-04-10 01:11:05
我在我的tesseract应用程序中遇到了同样的问题,我尝试了一下,它起作用了。
来源:cannot find name 'require' in angular 7(typescript 3.1.3)
https://stackoverflow.com/questions/60322215
复制相似问题